views:

192

answers:

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.

+1  A: 

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

klausbyskov