Silverlight mouse event processing, silverlight event
Hosting code registration mouse events
You do not need to declare registration events in. xaml.
. Xaml
<Ellipse Name="ellipse" Width="120" Height="120" Fill="Orange" Canvas.Top="60" Canvas.Left="80"/>
Different from registering an event in. xaml
<Ellipse Name="ellipse" Width="120" Height="120" Fill="Orange" Canvas.Top="60" Canvas.Left="80" MouseEnter="OnMouseEnter"/>
Then, register the mouse event in. c # and place it in MainPage.
public MainPage() { InitializeComponent(); ellipse.MouseEnter += new MouseEnterHander(OnMouseEnter); ellipse.MouseLeave += new MouseEnterHander(OnMouseEnter);
}
void OnMouseEnter(object sender, MouseEventArgs e)
{
Ellipse m = sender as Ellipse;
m.Fill=new SolidColorBrush(Color.Green);
}
When obtaining the time, you can
Ellipse. MouseEnter + = directly attach the Tab
public MainPage() { InitializeComponent(); ellipse.MouseEnter += Ellipse_MouseEnter; ellipse.MouseLeave += Ellipse_MouseLeave; } private void Ellipse_MouseLeave(object sender,MouseEventArgs e) { Ellipse ell = sender as Ellipse; ell.Fill = new SolidColorBrush(Colors.Gray); } private void Ellipse_MouseEnter(object sender, MouseEventArgs e) { Ellipse ell = sender as Ellipse; ell.Fill = new SolidColorBrush(Colors.Black); }