<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;
}
}