"Property value is invalid." Why does visual studio not allow me to assign an image to an image?

In a WPF window, I have an image object. I clicked a button to assign a source, a window appeared for it, I added an image there (click "Add"). When the image was loaded, instead of showing the image, it simply showed a white square. I am trying to designate this white box as the source of the image, and it just says: "The value of the property is invalid." The solution researcher clearly shows that there are images, and I can double-click and open them for editing. So why doesn't VS like the way I try to assign images to my wpf image object? I have added images to WPF projects several times using this method.

+4
source share
4 answers

In case other people read this, restarting Visual Studio may help.

+10
source

I had a similar problem only with VS 2012. This was due to the fact that I gave one of my UserControl a NameProperty of "This" to internally reference some of the dependency properties I'd used for controls.

Do not specify the UserControl a Name="This" property in XAML. This is perplexing.

+2
source

I had the same problem. Because images refer to the project as resources that they need to be compiled into the project. Therefore, in my case, I added them to the solution, and then built a project. At this point, they were available to control the image.

+1
source

So, it turns out that the reason for this particular error was the space in the name of my solution. I assume that this caused a space in the path for the image that VS simply could not process. Strange, but that’s all.

+1
source

Source: https://habr.com/ru/post/1400283/


All Articles