private static object OnCoerce_Icon(DependencyObject o, object value) { if (value is string) { Uri iconUri; // try to resolve given value as an absolute URI if (Uri.TryCreate(value as String, UriKind.RelativeOrAbsolute, out iconUri)) { ImageSource img = new BitmapImage(iconUri); if (null != img) { GreyableImage icon = (o as ManagedContent).Icon as GreyableImage; if (null == icon) { icon = new GreyableImage(); } icon.Source = img; icon.Stretch = Stretch.None; icon.SnapsToDevicePixels = true; return(icon); } } } return(value); }
private static object OnCoerce_Icon(DependencyObject o, object value) { if (value is string) { Uri iconUri; // try to resolve given value as an absolute URI if (Uri.TryCreate(value as String, UriKind.RelativeOrAbsolute, out iconUri)) { ImageSource img = new BitmapImage(iconUri); if (null != img) { GreyableImage icon = (o as ManagedContent).Icon as GreyableImage; if (null == icon) icon = new GreyableImage(); icon.Source = img; icon.Stretch = Stretch.None; icon.SnapsToDevicePixels = true; return icon; } } } return value; }