WPF VB.Net Tutorial

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="200" Width="300">
    
        
            
                
            
        

        
        
            
                
                    
                    
                
                
                    
                    
                
            
            
                
                    
                    
                    
                
                
                    
                    
                    
                
            
        
    

//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub
    Private Sub TreeViewItem_Selected(sender As Object, e As RoutedEventArgs)
      Dim item As TreeViewItem = TryCast(sender, TreeViewItem)
      If item Is e.OriginalSource Then
        Console.WriteLine(item.Header)
        Console.WriteLine(item.Items.Count)
      Else
        Console.WriteLine("Parent of selected")
        Console.WriteLine(item.Header)
        Console.WriteLine(item.Items.Count)
      End If
    End Sub
    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
      Dim item As TreeViewItem = TryCast(tvTree.SelectedItem, TreeViewItem)
      If item IsNot Nothing Then
        MessageBox.Show("Item selected: " & Convert.ToString(item.Header), Title)
      Else
        MessageBox.Show("No item selected", Title)
      End If
    End Sub
  End Class
End Namespace