Not sure if I understand your requirement correctly ... is this what you want?
CommandParameter="{Binding Path={x:Static local:TestEnum.First}}"
EDIT: OK, I think now I understand ... If you want the enumeration values ββto be an ItemsSource , you could do it with an ObjectDataProvider , but there is a better way: write a markup extension that takes the enumeration type and returns the values.
Markup extension
[MarkupExtensionReturnType(typeof(Array))] public class EnumValuesExtension : MarkupExtension { public EnumValuesExtension() { } public EnumValuesExtension(Type enumType) { this.EnumType = enumType; } [ConstructorArgument("enumType")] public Type EnumType { get; set; } public override object ProvideValue(IServiceProvider serviceProvider) { return Enum.GetValues(EnumType); } }
Xaml
<MenuItem ItemsSource="{my:EnumValues EnumType=my:TestEnum}" Name="menu"> <MenuItem.ItemContainerStyle> <Style TargetType="MenuItem"> <Setter Property="Header" Value="{Binding}" /> <Setter Property="Command" Value="{Binding SomeCommand, ElementName=menu}" /> <Setter Property="CommandParameter" Value="{Binding}" /> </Style> </MenuItem.ItemContainerStyle> </MenuItem>
source share