LocalizedEnumValuesExtension Class

XAML markup extension that provides localized enum values with display names from DisplayAttribute.

public sealed class LocalizedEnumValuesExtension : MarkupExtension

Example

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:wpf="clr-namespace:Meziantou.Framework.WPF;assembly=Meziantou.Framework.WPF"
             xmlns:local="clr-namespace:Meziantou.Framework.WPF.EnumComboBox">
    <!-- Displays the names from the [Display] attributes of the enum members -->
    <ComboBox ItemsSource="{wpf:LocalizedEnumValues {x:Type local:Week}}" DisplayMemberPath="Name" SelectedValuePath="Value" />
</UserControl>
Inheritance
MarkupExtension LocalizedEnumValuesExtension

Constructors

NameDescription
LocalizedEnumValuesExtension()Initializes a new instance of the LocalizedEnumValuesExtension class.
LocalizedEnumValuesExtension(Type)Initializes a new instance of the LocalizedEnumValuesExtension class with the specified enum type.

LocalizedEnumValuesExtension overloads

LocalizedEnumValuesExtension()

LocalizedEnumValuesExtension.cs

Initializes a new instance of the LocalizedEnumValuesExtension class.

public LocalizedEnumValuesExtension()

LocalizedEnumValuesExtension(Type)

LocalizedEnumValuesExtension.cs

Initializes a new instance of the LocalizedEnumValuesExtension class with the specified enum type.

public LocalizedEnumValuesExtension(Type enumType)
Parameters
enumType Type
The enum type.

Properties

NameDescription
EnumTypeGets or sets the enum type to get localized values from.

Gets or sets the enum type to get localized values from.

public Type? EnumType { get; set; }

Property value

Type?

Methods

NameDescription
ProvideValue(IServiceProvider)Returns the localized enum values.

ProvideValue(IServiceProvider)

LocalizedEnumValuesExtension.cs

Returns the localized enum values.

public override object ProvideValue(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

Returns

object