<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Margin="0,2,0,15" Content="有提示的按鈕" Click="Button_Click"/>
<StackPanel Grid.Row="1">
<Button Content="有提示的按鈕" Margin="0,2,0,15" Click="Button_Click_1"/>
<TextBlock Name="text" FontSize="32"/>
</StackPanel>
</Grid>
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("沒有提示的按鈕");
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MessageBoxResult res = MessageBox.Show("有按鈕的提示", "提示按鈕", MessageBoxButton.OKCancel);
switch(res){
case MessageBoxResult.Cancel:
this.text.Text = "你取消了按鈕";
break;
case MessageBoxResult.OK:
this.text.Text = "你點擊了按鈕";
break;
}
}