Click here to Skip to main content
15,167,925 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Using custom fonts in WPF project Pin
Alex Dunlop14-Nov-21 18:29
MemberAlex Dunlop14-Nov-21 18:29 
GeneralRe: Using custom fonts in WPF project Pin
#realJSOP15-Nov-21 0:25
mva#realJSOP15-Nov-21 0:25 
GeneralRe: Using custom fonts in WPF project Pin
Dave Kreskowiak15-Nov-21 2:43
mveDave Kreskowiak15-Nov-21 2:43 
QuestionCommon StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Amarnath S4-Nov-21 4:20
professionalAmarnath S4-Nov-21 4:20 
AnswerRe: Common StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Gerry Schmitz4-Nov-21 6:36
mveGerry Schmitz4-Nov-21 6:36 
GeneralRe: Common StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Amarnath S4-Nov-21 7:48
professionalAmarnath S4-Nov-21 7:48 
GeneralRe: Common StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Gerry Schmitz4-Nov-21 11:20
mveGerry Schmitz4-Nov-21 11:20 
QuestionVB.net - WPF - Help with treeview Pin
Lasse Frederiksen31-Oct-21 21:55
MemberLasse Frederiksen31-Oct-21 21:55 
I am new to VB.net and WPF.
and i need some help.

When i select a item in the combobox.
then i will have that Directory i have selected in the combobox. add to the listbox or treeview (as a treeview with folders/subfolders/... and files)

edit:
My problem is i apparently can't use .Nodes in my VB.net code.
And my events (afterselected) is useless..

I can use it in VB.net(winforms) but not as WPF (Class Library)

VB.NET
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Input

Public Class VerticalPaneExample
    Dim root = "c:\temp\"
    Dim matroot As String = ""
    Dim newtoolsti As String = ""
    Dim enodetext As String = ""


    Private Sub VerticalPaneExample_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        Dim folders() As String = IO.Directory.GetDirectories(root)
        For Each folder As String In folders
            Dim clean As String
            clean = folder.Replace(root, "")
            Me.matpicker.Items.Add(clean)
        Next
    End Sub

    Private Sub matpicker_AfterSelect(sender As Object, e As RoutedEventArgs) Handles matpicker.AfterSelect
        Me.matpicker.SelectedItem = matroot

        For Each direct As String In System.IO.Directory.GetDirectories(matroot)
            Dim dir As String = System.IO.Path.GetFileNameWithoutExtension(direct)
            Dim newNode = viewptffiles.Nodes.Add(dir, dir)
            RecurseChildFolders(direct, newNode)
            Try
                For Each file As String In System.IO.Directory.GetFiles(direct, "*.*")
                    newNode.Nodes.Add(System.IO.Path.GetFileName(file))
                Next
            Catch ex As Exception
            End Try
        Next

    Private Sub RecurseChildFolders(directory As String, parent As TreeNode)
        For Each direct As String In System.IO.Directory.GetDirectories(directory)
            Dim dir As String = System.IO.Path.GetFileNameWithoutExtension(direct)
            Dim child = parent.Nodes.Add(dir, dir)
            RecurseChildFolders(direct, child)
            Try
                For Each file As String In System.IO.Directory.GetFiles(direct, "*.*")
                    child.Nodes.Add(System.IO.Path.GetFileName(file))
                Next
            Catch ex As Exception
            End Try
        Next
    End Sub

End Class


My xaml file look like this:
XML
<pre><UserControl x:Class="VerticalPaneExample"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:ExamplePowerMillPluginVB"
             mc:Ignorable="d" 
             d:DesignHeight="1000" 
             d:DesignWidth="450"
             Background="White">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10"/>          <!-- magin -->
            <ColumnDefinition Width="380"/>         <!-- in -->
            <ColumnDefinition Width="10"/>          <!-- magin -->
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="10"/>            <!-- magin -->
            <RowDefinition Height="auto"/>          <!-- combobox matriale picker -->
            <RowDefinition Height="10"/>            <!-- magin -->
            <RowDefinition Height="auto"/>          <!-- treeview -->
            <RowDefinition Height="10"/>            <!-- magin -->
            <RowDefinition Height="auto"/>          <!-- import toolbutton -->
            <RowDefinition Height="auto"/>            <!-- magin -->
        </Grid.RowDefinitions>
		
		
        <ComboBox
            x:Name="matpicker"
            Grid.Row="1" 
            Grid.Column="1"
            Height="20"
            Width="380" 
            SelectedIndex="-1"
        ></ComboBox>

        <ListBox 
            x:Name="viewptffiles"
            Grid.Row="3" 
            Grid.Column="1" 
            Height="500" 
            Width="380"
            />

		<Button 
            x:Name="Importt"
            Content="Import Tool"
            Grid.Row="5" 
            Grid.Column="1"
            Height="40"
        />
    </Grid>
</UserControl>


modified 1-Nov-21 6:39am.

AnswerRe: VB.net - WPF - Help with treeview Pin
Richard Deeming1-Nov-21 0:11
mveRichard Deeming1-Nov-21 0:11 
GeneralRe: VB.net - WPF - Help with treeview Pin
Lasse Frederiksen1-Nov-21 0:44
MemberLasse Frederiksen1-Nov-21 0:44 
GeneralRe: VB.net - WPF - Help with treeview Pin
Richard Deeming1-Nov-21 2:27
mveRichard Deeming1-Nov-21 2:27 
QuestionDataGridCell Style Problem Pin
Kevin Marois25-Oct-21 12:20
professionalKevin Marois25-Oct-21 12:20 
QuestionWPF MVVM Modeless Dialogs - any Example? Pin
Amarnath S23-Oct-21 22:08
professionalAmarnath S23-Oct-21 22:08 
AnswerRe: WPF MVVM Modeless Dialogs - any Example? Pin
Gerry Schmitz24-Oct-21 10:22
mveGerry Schmitz24-Oct-21 10:22 
GeneralRe: WPF MVVM Modeless Dialogs - any Example? Pin
#realJSOP10-Nov-21 0:24
mva#realJSOP10-Nov-21 0:24 
AnswerRe: WPF MVVM Modeless Dialogs - any Example? Pin
#realJSOP10-Nov-21 0:30
mva#realJSOP10-Nov-21 0:30 
QuestionHow do I create xy plots with WPF APP (.NET Framework)? --- Solved Pin
Member 1539432815-Oct-21 6:12
MemberMember 1539432815-Oct-21 6:12 
AnswerRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Richard Deeming15-Oct-21 7:05
mveRichard Deeming15-Oct-21 7:05 
AnswerRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz15-Oct-21 10:23
mveGerry Schmitz15-Oct-21 10:23 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Member 1539432815-Oct-21 10:28
MemberMember 1539432815-Oct-21 10:28 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz15-Oct-21 11:03
mveGerry Schmitz15-Oct-21 11:03 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Member 1539432816-Oct-21 2:40
MemberMember 1539432816-Oct-21 2:40 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Eddy Vluggen16-Oct-21 4:13
professionalEddy Vluggen16-Oct-21 4:13 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz16-Oct-21 10:46
mveGerry Schmitz16-Oct-21 10:46 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? --- Solved Pin
Member 1539432817-Oct-21 5:44
MemberMember 1539432817-Oct-21 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.