Change image source in code behind - Wpf

后端 未结 5 1795
醉酒成梦
醉酒成梦 2020-12-24 06:43

I need to set image source dynamically, please note my image is in somewhere on the Network, here is my code

BitmapImage logo = new BitmapImage();
logo.Begin         


        
5条回答
  •  醉梦人生
    2020-12-24 07:28

    The pack syntax you are using here is for an image that is contained as a Resource within your application, not for a loose file in the file system.

    You simply want to pass the actual path to the UriSource:

    logo.UriSource = new Uri(@"\\myserver\folder1\Customer Data\sample.png");
    

提交回复
热议问题