1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Editors
7 using System.Globalization;
8 using System.Diagnostics.CodeAnalysis;
9 using System.Windows.Controls;
10 using System.Windows.Data;
11 using System.Windows.Media;
13 using System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.PropertyInspector;
14 using System.Activities.Presentation;
17 // Converter that takes an object and either returns it
18 // or wraps it in an Image control if the object is of type ImageSource.
19 // This class gets instantiated from XAML.
21 [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
22 internal class ImageSourceToImageConverter : IValueConverter
24 // IValueConverter Members
26 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
29 ImageSource imageSource = value as ImageSource;
31 if (imageSource == null)
36 Image image = new Image();
37 image.Source = imageSource;
41 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
43 throw FxTrace.Exception.AsError(new InvalidOperationException());