//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 Button_Click(sender As Object, e As RoutedEventArgs) Dim item As ComboBoxItem = TryCast(comboBox.SelectedItem, ComboBoxItem) If item IsNot Nothing Then MessageBox.Show("Current item: " & Convert.ToString(item.Content), Title) ElseIf Not [String].IsNullOrEmpty(comboBox.Text) Then MessageBox.Show("Text entered: " + comboBox.Text, Title) End If End Sub Private Sub ComboBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) If Not IsInitialized Then Return End If Dim item As ComboBoxItem = TryCast(comboBox.SelectedItem, ComboBoxItem) If item IsNot Nothing Then MessageBox.Show("Selected item: " & Convert.ToString(item.Content), Title) End If End Sub Private Sub ComboBoxItem_Selected(sender As Object, e As RoutedEventArgs) If Not IsInitialized Then Return End If Dim item As ComboBoxItem = TryCast(e.OriginalSource, ComboBoxItem) If item IsNot Nothing Then MessageBox.Show(Convert.ToString(item.Content) & " was selected.", Title) End If End Sub End Class End Namespace