我有以下代码:
<Grid>
<Canvas Grid.Row="0" x:Name="drawingSurface" Background="White" ClipToBounds="True"
MouseLeftButtonDown="drawingSurface_MouseLeftButtonDown"
MouseLeftButtonUp="drawingSurface_MouseLeftButtonUp"
MouseMove="drawingSurface_MouseMove">
</Canvas>
<Grid Name="pnlProperties" Visibility="Hidden"/>
</Grid>
启动此窗口后,用户选择他感兴趣的区域(我抓住MouseMove
,MouseLeftButtonDown
,MouseLeftButtonUp
。)
然后我想在左角的所选区域下显示面板pnlProperties(在我感兴趣的坐标中)。
我该怎么做?
答案 0 :(得分:1)
将Grid
放入Canvas
,然后设置Grid
的坐标,使用:
YourCanvas.SetLeft(pnlProperties, MOUSE.X)
YourCanvas.SetTop(pnlProperties, MOUSE.Y);