1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Editors
7 using System.Windows.Data;
8 using System.Globalization;
10 using System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.PropertyInspector;
11 using System.Activities.Presentation;
14 // Converts an instance of NewItemFactoryTypeModel to its appropriate display name.
15 // One way binding to NewItemFactoryTypeModel's DisplayName property also works, but
16 // for the sake of having a single place that converts NewItemFactoryTypeModel to
17 // strings, we expose this internal converter.
19 internal class NewItemFactoryTypeModelToDisplayNameConverter : IValueConverter
22 private static NewItemFactoryTypeModelToDisplayNameConverter _instance;
25 // Static instance accessor for all non-XAML related conversion needs
27 public static NewItemFactoryTypeModelToDisplayNameConverter Instance
30 if (_instance == null)
32 _instance = new NewItemFactoryTypeModelToDisplayNameConverter();
39 // Converts an instance of NewItemFactoryTypeModel to its appropriate display name
40 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
43 if (typeof(string).IsAssignableFrom(targetType))
46 NewItemFactoryTypeModel model = value as NewItemFactoryTypeModel;
49 return model.DisplayName ?? string.Empty;
56 // This class is only a one-way converter
57 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
59 throw FxTrace.Exception.AsError(new InvalidOperationException());