Loading images source dynamically with IValueConverter

我们两清 提交于 2019-11-29 15:44:36

If you create the URI in code you have to write the full Pack URI including the pack://application:,,, part. In XAML this is not necessary as it is automatically added by the string-to-ImageSource TypeConverter.

var type = (string)value;
var uri = new Uri("pack://application:,,,/XConsole;component/Images/" + type + ".png");

Note that the above code sample uses a lowercase type identifier instead of Type to avoid confusion with the Type class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!