Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing an enum value as command parameter from XAML

Try this

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

local - is your namespace reference in the XAML


Also remember that if your enum is inside another class you need to use the + operator.

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

You can use property element syntax instead of attribute syntax for this:

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

Also if you want to provide a [Flags] enum you can use the property element syntax:

<Button>
  <Button.CommandParameter>
    <SearchPageType>First,Second</SearchPageType>
  <Button.CommandParameter>
</Button>