For your dialog you can use something like
Dim result As MessageBoxResult = MessageBox.Show("Message Test", "Caption", MessageBoxButtons.OKCancel)
Select Case result
Case MessageBoxResult.OK
Case MessageBoxResult.Cancel
End Select
This will give you a modal message box with ok/cancel options.
You can then decide what to do using the case statement.
To make a custom dialog you can use something like this.
Here is a quick example.
XAML
<Window x:Class="MessageWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DialogWindow" Height="150" MaxHeight="450" Width="400" MaxWidth="600" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
<StackPanel Orientation="Horizontal">
<Button Name="btnYes" Content="Yes" Click="btnYes_Click"></Button>
<Button Name="btnNo" Content="No" Click="btnNo_Click"></Button>
<Button Name="btnCancel" Content="Cancel" Click="btnCancel_Click"></Button>
</StackPanel></Window>
VB
Public Class MessageWindow
Private _messageResponse As MessageBoxResult
Public Property MessageResponse As MessageBoxResult
Get
Return _messageResponse
End Get
Set(value As MessageBoxResult)
_messageResponse = value
End Set
End Property
Private Sub btnYes_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
DialogResult = True
_messageResponse = MessageBoxResult.Yes
Me.Close()
End Sub
Private Sub btnNo_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
DialogResult = False
_messageResponse = MessageBoxResult.No
Me.Close()
End Sub
Private Sub btnCancel_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
DialogResult = False
_messageResponse = MessageBoxResult.Cancel
Me.Close()
End Sub
End Class
You can then use it like this
Dim messageWindow As New MessageWindow()
messageWindow.ShowDialog()
Dim result As MessageBoxResult = messageWindow.MessageResponse
'handle response
Note if you only have two possible responses then you can use the dialogresult property of Window which is returned from the showdialog function of window. E.g. You can use dialogresult = true for OK and dialogresult = false for cancel.