How to programmatically set the Image source

后端 未结 6 1102
囚心锁ツ
囚心锁ツ 2021-02-01 14:16

When the Image\'s Source property is set the following way, the picture is taken from /Images/down.png.

How would I do the same thing programmatically?

6条回答
  •  太阳男子
    2021-02-01 14:37

    myImg.Source = new BitmapImage(new Uri(@"component/Images/down.png", UriKind.RelativeOrAbsolute)); 
    

    Don't forget to set Build Action to "Content", and Copy to output directory to "Always".

提交回复
热议问题