I'd like to create my custom error/exception dialog with the standard Windows "Error icon".
I followed the advice from this question and it works.
However I'm currently creating an instance property I bind to just like to any property:
class ErrorWindowViewModel
{
private readonly ImageSource _errorImage;
public ImageSource ErrorImage { get { return _errorImage; } }
public ErrorWindowViewModel()
{
_errorImage = Imaging.CreateBitmapSourceFromHIcon(SystemIcons.Error.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
}
What I'd like to do is to have a static field defined in my ErrorWindow class:
partial class ErrorWindow : Window
{
private readonly static ImageSource ErrorImage =
Imaging.CreateBitmapSourceFromHIcon(SystemIcons.Error.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
I can't force my XAML to reference that field.
<Image Source="what_to_put_here_to_make_it_work" />
I'm using WPF 4.5.