how to add images from file location WPF

后端 未结 2 1342
既然无缘
既然无缘 2020-12-31 06:34

Am stuck to load images from my file location in WPF.

here is my xaml



        
2条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 06:53

    If it's a file located somewhere on the drive (not a resource), better use an ABSOLUTE path:

    image.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "image.png", UriKind.Absolute));
    

    This code detects the running folder and builds the path relative to it

提交回复
热议问题