3-WPF-Order/5-WPF样式和行为-4关联事件处理程序/MainWindow.xaml.cs

27 lines
668 B
C#

using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace _5_WPF样式和行为_4关联事件处理程序;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
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;
}
}