mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-30 01:40:51 +02:00
cleanup
This commit is contained in:
@ -22,15 +22,16 @@ namespace ModernWpfPlayground.PropertyPresenter2
|
||||
/// <summary>
|
||||
/// Returns the content of a description attribute of an enum.
|
||||
/// </summary>
|
||||
/// <param name="enumValue"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private static string GetDescription(object enumValue)
|
||||
private static string GetDescription(object value)
|
||||
{
|
||||
if (!(value is Enum enumValue)) return string.Empty;
|
||||
var descriptionAttribute = enumValue.GetType()
|
||||
.GetField(enumValue.ToString()).GetCustomAttributes(false)
|
||||
.OfType<DescriptionAttribute>().FirstOrDefault();
|
||||
|
||||
return descriptionAttribute?.Description ?? enumValue.ToString();
|
||||
return descriptionAttribute?.Description ?? value.ToString();
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
@ -12,20 +12,20 @@ namespace ModernWpfPlayground.PropertyPresenter2
|
||||
/// <summary>
|
||||
/// Default data template. (currently Textbox)
|
||||
/// </summary>
|
||||
public DataTemplate DefaultDataTemplate { private get; set; }
|
||||
public DataTemplate? DefaultDataTemplate { private get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data template for boolean. (currently Checkbox)
|
||||
/// </summary>
|
||||
public DataTemplate BooleanDataTemplate { private get; set; }
|
||||
public DataTemplate? BooleanDataTemplate { private get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data template for enums. (currently Combobox)
|
||||
/// </summary>
|
||||
public DataTemplate EnumComboBoxDataTemplate { private get; set; }
|
||||
public DataTemplate? EnumComboBoxDataTemplate { private get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
public override DataTemplate? SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
return item switch
|
||||
{
|
||||
|
Reference in New Issue
Block a user