using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; namespace _5_WPF样式和行为_4关联事件处理程序; /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void EventSetter_MoueEnter(object sender, MouseEventArgs e) { ((TextBlock)sender).Background = new SolidColorBrush(Colors.LightGoldenrodYellow); } private void EventSetter_MouseLeave(object sender, MouseEventArgs e) { ((TextBlock)sender).Background = null; } }