Set imagesource of wpf image
-
31-05-2021 - |
문제
I know that there are a few similiar questions but they don´t help me:
Have got the following code to show a Image in code behind:
BitmapImage logo = new BitmapImage();
logo.BeginInit();
logo.UriSource = new `Uri("pack://application:,,,/ApplicationName;component/Images/Klar.JPG");`
logo.EndInit();
The image is in the Images folder at the same level as the bin
folder.
What is my mistake?
해결책
For information about Pack URIs see here. I believe yours should be:
logo.BeginInit();
logo.UriSource = new Uri("pack://application:,,,/Images/Klar.JPG");
logo.EndInit();
which assumes that at the project level you have a folder called Images which contains a jpg called Klar.JPG.
제휴하지 않습니다 StackOverflow