1、C#代码如下:
public class logotoimgConverter:IValueConverter { //将logo转换为URI public object Convert(object value, Type targetType, object parameter, string language) { logo c = (logo)value; switch (c) { case logo.Baidu: return @"/Assets/Baidu.png"; case logo.Google: return @"/Assets/Google.png";// /这个才是/正斜杠 default: return null; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } }
2、在XAML中,
resource中有
而在相对应要转换值的绑定的控件加入