Frage

I have my xaml in a string which i render as a grid using a converter. However I get this exception.

*Cannot convert string '../../Resources/info_16_hot.png' in attribute 'Source' to object of type 'System.Windows.Media.ImageSource'. Cannot locate resource 'resources/info_16_hot.png'*

Here is the snippet of the XAML string

string m_image = "<Image Stretch='Fill' HorizontalAlignment='Center' VerticalAlignment='Center' Width='16' Height='16' Source='../../Resources/info_16_hot.png' />";

Resources directory is the same directory & info_16_hot.png is marked as a Resource , Do not Copy. Moving the file to the same directory and updating the source to Source='info_16_hot.png' still does not help.

War es hilfreich?

Lösung

if its marked as a resource you have to use it like this:

Source='/namespace;component/Resources/info_16_hot.png'

where you replace namespace with the name of your namespace.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top