How to get tap in lower control?

mc 5,511 Reputation points
2022-12-21T03:16:38.423+00:00
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >  
        <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch"   
                Tapped="Canvas_Tapped" >  
        </Canvas>  
    </StackPanel>  

I can not get Tapped in canvas?

Windows development | Windows App SDK
0 comments No comments
{count} votes

Accepted answer
  1. Junjie Zhu - MSFT 21,646 Reputation points
    2022-12-21T06:24:23.397+00:00

    Hello @mc ,
    Welcome to Microsoft Q&A!

    Your original code canvas actually runs with a Height and Width of Zero.
    You can try to test with the following code.

    <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >  
            <Canvas Background="Black" Height="500" Width="600" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"   
                     Tapped="Canvas_Tapped" >  
            </Canvas>  
    </StackPanel>  
    

    Thank you
    Junjie


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.