private void Button_Click_1(object sender,EventArgs e)
{
MessageBox.Show("Wonderful!");
}
<Window x:Class="鳄鱼啊鳄鱼.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Background>
<LinearGradientBrush>
<GradientStop Offset="0" Color="Blue"></GradientStop>
<GradientStop Offset="0.5" Color="LightBlue"></GradientStop>
</LinearGradientBrush>
</Grid.Background>
<TextBox Height="23" Margin="10,10,10,0" Name="textBox1" VerticalAlignment="Top" Text="{Binding ElementName=slider1, Path=Value, UpdateSourceTrigger=PropertyChanged}" TextChanged="textBox1_TextChanged" />
<Slider Height="21" Margin="10,40,10,0" Name="slider1" VerticalAlignment="Top" Maximum="100" />
<Button Content="Button" HorizontalAlignment="Left" Height="50" Margin="48,172,0,0" VerticalAlignment="Top" Width="138" Click="Button_Click"/>
<Label Content="当前时间--" HorizontalAlignment="Left" Height="66" Margin="263,172,0,0" VerticalAlignment="Top" Width="204"/>
<Button Content="Button1" HorizontalAlignment="Left" Height="52" Margin="48,258,0,0" VerticalAlignment="Top" Width="125" Click="Button_Click_1"/>
<CheckBox Content="CheckBox" HorizontalAlignment="Left" Height="39" Margin="263,245,0,0" VerticalAlignment="Top" Width="109" Checked="CheckBox_Checked"/>
<ComboBox HorizontalAlignment="Left" Margin="335,91,0,0" VerticalAlignment="Top" Width="120" SelectionChanged="ComboBox_SelectionChanged"/>
</Grid>
</Window>
原文:http://www.cnblogs.com/caymanlu/p/5829446.html