how to diplay image in canvas?

mc 6,136 Reputation points
2022-12-22T09:53:12.343+00:00

<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="300">
<Image Source="ic.png" Canvas.Left="10" Canvas.Top="10" Width="30" Height="30"/>
</Canvas>

but there is nothing.

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

Answer accepted by question author
  1. Junjie Zhu - MSFT 21,731 Reputation points
    2022-12-23T02:56:37.21+00:00

    Hello @mc
    Welcome to Microsoft Q&A!

    The reason why your image is not displayed is that your image cannot be found after the program is packaged.
    It is recommended that you put the images in the Assets directory.

    <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="300">  
            <Image Source="Assets/ic.png" Canvas.Left="10" Canvas.Top="10" Width="30" Height="30"/>  
    </Canvas>  
    

    273523-microsoftteams-image-7.png

    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.