I have a Parent Canvas.That Parent Canvas has two child Canvas One over another with same height and width.Fisrt child Canvas has zindex=0,and second child Canvas has zindex=1.The second Child Canvas has many child Image(UIElement).i want,my second canvas must have higher zindex.I have PointerPressed event for first canvas , second canvas and on each Image also.I want,if I Click on image it fire PointerPressed event of the Image and if I click on canvas where the image is not present ,it must fire first canvas pointerPressed event whose zindex is 0.I don't know how to achieve this??
My XAML Code:
<Canvas x:Name="MyCanvas">
<Canvas x:Name="FirstCanvas" Canvas.ZIndex="0" PointerPressed="FirstCanvas_PointerPressed" Width="1500" Height="700">
<!--Child Elements-->
</Canvas>
<Canvas x:Name="SecondCanvas" Canvas.ZIndex="1" PointerPressed="SecondCanvas_PointerPressed" Width="1500" Height="700">
<Image x:Name="FistImage" Source="image1.jpg" Width="100" Height="100" PointerPressed="FistImage_PointerPressed" Canvas.Left="0" Canvas.Top="0"></Image>
<Image x:Name="SecondImageImage" Source="image2.jpg" Width="100" Height="100" PointerPressed="SecondImageImage_PointerPressed" Canvas.Left="200" Canvas.Top="200"></Image>
</Canvas>
</Canvas>
My C# Code:
private void FirstCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
{
}
private void SecondCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
{
}
private void FistImage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
}
private void SecondImageImage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
}
PointerPressed
event of the picture will be triggered, and will not continue to trigger thePointerPressed
event of TopCanvas? – Richard Zhang - MSFTPointerPressed
event occurs on the Image, and secondly,FirstCanvas
is not the parent element of the Image, and the event will not bubble through theFirstCanvas
. – Richard Zhang - MSFT