<DockPanel MouseMove="DockPanel_MouseMove" Width="300" Height="200" VerticalAlignment="Center" HorizontalAlignment="Center" Background="White">
<Border BorderBrush="Silver" BorderThickness="3">
<Grid>
<TextBlock Name="txt" Text="test"></TextBlock>
</Grid>
</Border>
</DockPanel>
private void DockPanel_MouseMove(object sender, MouseEventArgs e)
{
Point p = e.GetPosition((IInputElement)sender);
txt.Text = "x:" + p.X + " y:" + p.Y;
}
使ç¨DockPanelç示ä¾å¦ä¸ä»£ç æ示ï¼æ³¨åMouseMoveäºä»¶ï¼å¨åå°è¿è¡å¤çå°±Okäº
温馨提示:答案为网友推荐,仅供参考