鼠标移动
添加一个显示鼠标位置的程序
private void Rectangle_MouseMove(object sender, MouseEventArgs e)
{
var point = e.GetPosition(this);
this.textBlock.Text = "X:" + point.X + " Y:" + point.Y;
}Code language: JavaScript (javascript)
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Fill="Black" MouseMove="Rectangle_MouseMove"></Rectangle>
<TextBlock Name="textBlock" Height="30" Grid.Row="1"></TextBlock>
</Grid>Code language: HTML, XML (xml)
Previous: 12-练习一下-输出文本框的各个事件触发
Next: 14-选项卡控件的使用