//File:Window.xaml.vb Imports System Imports System.Windows Namespace MessageBoxSample Public Partial Class MainWindow Inherits Window Public Sub New() InitializeComponent() End Sub Private Sub showMessageBoxButton_Click(sender As Object, e As RoutedEventArgs) Dim owner As Window = (If(CBool(ownerCheckBox.IsChecked), Me, Nothing)) Dim messageBoxText As String = Me.messageBoxText.Text Dim caption As String = Me.caption.Text Dim button As MessageBoxButton = CType([Enum].Parse(GetType(MessageBoxButton), Me.buttonComboBox.Text), MessageBoxButton) Dim icon As MessageBoxImage = CType([Enum].Parse(GetType(MessageBoxImage), Me.imageComboBox.Text), MessageBoxImage) Dim defaultResult As MessageBoxResult = CType([Enum].Parse(GetType(MessageBoxResult), Me.defaultResultComboBox.Text), MessageBoxResult) Dim options As MessageBoxOptions = CType([Enum].Parse(GetType(MessageBoxOptions), Me.optionsComboBox.Text), MessageBoxOptions) Dim result As MessageBoxResult If owner Is Nothing Then result = MessageBox.Show(messageBoxText, caption, button, icon, defaultResult, options) Else result = MessageBox.Show(owner, messageBoxText, caption, button, icon, defaultResult, _ options) End If resultTextBlock.Text = "Result = " & result.ToString() End Sub End Class End Namespace