Passing an enum value as command parameter from XAML

akjoshi picture akjoshi · Dec 11, 2008 · Viewed 61.2k times · Source

I want to pass an enum value as command parameter in WPF, using something like this:

<Button 
    x:Name="uxSearchButton" 
    Command="{Binding Path=SearchMembersCommand}" 
    CommandParameter="SearchPageType.First"
    Content="Search">
</Button>

SearchPageType is an enum and this is to know from which button search command is invoked.

Is this possible in WPF, or how can you pass an enum value as command parameter?

Answer

Jobi Joy picture Jobi Joy · Dec 11, 2008

Try this

<Button CommandParameter="{x:Static local:SearchPageType.First}" .../>

local - is your namespace reference in the XAML