Converting MessageBoxImage to ImageSource WPF

type-conversion, wpf, xaml

Solution

You should use `CreateBitmapSourceFromHIcon` method (msdn) and `SystemIcons` class (msdn).

Example:

img.Source = Imaging.CreateBitmapSourceFromHIcon(
                                SystemIcons.Warning.Handle,
                                Int32Rect.Empty,
                                BitmapSizeOptions.FromEmptyOptions());

Problem

I'm try to create a custom MessageBox in WPF(c#). I need to convert MessageBoxImage to ImageSource. Is there any way?

Original source