문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top