0
我無法得到爲什麼我的畫布不能獲取指針事件。下面我的代碼和XAML佈局的一部分:
XAML畫布不獲取指針事件
<Canvas
x:Name="cPad"
Canvas.ZIndex="99"
Grid.Column="0"
PointerPressed="Pad_PointerPressed">
<Rectangle
x:Name="rPicker"
Width="24"
Height="24"
Stroke="Black"
Fill="White"
StrokeThickness="3"/>
</Canvas>
C#
private void Pad_PointerPressed(object sender, PointerRoutedEventArgs e)
{
cPad.CapturePointer(e.Pointer);
var point = e.GetCurrentPoint(cPad).Position;
Canvas.SetLeft(rPicker, point.X);
Canvas.SetTop(rPicker, point.Y);
e.Handled = true;
}
,只有rPicker
動作,如果我點擊rPicker
...但我需要的問題到Pad_PointerPressed
爲畫布上的任何點執行。我怎麼做到的?
非常感謝您!我會盡力 –