WPF,这段代码啥意思?
<UserControl x:Class="WPFRoutedEvent.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<StackPanel>
<Button x:Name="testButton" Content="testButton" Click="TestButton_Click" />
</StackPanel>
</Grid>
</UserControl>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void TestButton_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(string.Format("sender 类型:{0} \n\r source 类型:{1} \n\r originalSource 类型: {2}",
sender.GetType().Name, e.Source.GetType().Name, e.OriginalSource.GetType().Name), "子窗体消息");
}
}
<Window x:Class="WPFRoutedEvent.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"
xmlns:local="clr-namespace:WPFRoutedEvent">
<Grid>
<local:UserControl1 x:Name="test1"/>