ten sposób użyłem ikonę System w XAML:
xmlns:draw="clr-namespace:System.Drawing;assembly=System.Drawing"
...
<Image Source="{Binding Source={x:Static draw:SystemIcons.Warning},
Converter={StaticResource IconToImageSourceConverter},
Mode=OneWay}" />
użyłem tego konwertera, aby włączyć ikonę do ImageSource :
public class IconToImageSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var icon = value as Icon;
if (icon == null)
{
Trace.TraceWarning("Attempted to convert {0} instead of Icon object in IconToImageSourceConverter", value);
return null;
}
ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
icon.Handle,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
return imageSource;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Chcesz ten sam obraz, niezależnie od platformy, lub chcesz ikonę odpowiadającą aktualnej wersji systemu Windows (łącznie z przyszłymi wersjami)? –
Idealnie, ikona, która wygląda jak standardowa ikona dla tej wersji systemu Windows. Ale mogę zadowalać się uzyskaniem standardu dla Vista/7. – RandomEngy