示例#1
0
        private static void OnBitmapPropertyChanged(DependencyObject source,
                                                    DependencyPropertyChangedEventArgs e)
        {
            BitmapImage image = source as BitmapImage;

            image._bitmap = e.NewValue as System.Drawing.Bitmap;
            if (image._bitmap != null)
            {
                image.Source = ToBitmapSource.Bitmap2BitmapSource(image._bitmap);
            }
        }
 public object Convert(object value, Type targetType, object parameter,
                       System.Globalization.CultureInfo culture)
 {
     if (value is Bitmap bitmap)
     {
         var source = ToBitmapSource.Bitmap2BitmapSource(bitmap);
         if (targetType == typeof(System.Windows.Media.ImageSource))
         {
             return(source);
         }
         var img = new BitmapImage {
             Source = source
         };
         return(img);
     }
     return(null);
 }