1

I am trying to bind a Enum to CommandParameters of a button. This cannot be static due to the fact that the button occurs in a ItemsControl.

Here is the Datatemplate:

<DataTemplate>
   <Button Command="{Binding MyCommand}" CommandParameters="{Binding MyEnumParameter}" Text="{Binding MyText}" />
</DataTemplate>

I am not sure what I need to do as the exception is Cannot convert enum to String. My guess is I will need a ValueConverter for this please verify if that is the only route for this.

cjibo
  • 4,487
  • 6
  • 27
  • 34
  • for anyone who is also trying to pass an enum as a command parameter [here](http://stackoverflow.com/questions/359699/passing-an-enum-value-as-command-parameter-from-xaml) is SO post including several variations of the solution. – XAMlMAX Aug 16 '14 at 20:24

1 Answers1

1

Yes, using a ValueConverter would be the right thing to do. This thread has en example you can use.

Community
  • 1
  • 1
Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222