WPF: “Value of type 'String' cannot be converted to 'System.Windows.Media.ImageSource'.”

后端 未结 5 1960
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 16:42

I\'m trying to set a WPF Image\'s source.

XAML works:


<         


        
5条回答
  •  猫巷女王i
    2021-01-12 17:29

    WPF uses an implicit type converter to convert the xaml string to the expected type. In code you are statically bound by the object type... If you look at the example here it shows how to set the source property to a BitmapImage that is generated from a local uri programatically.

提交回复
热议问题