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
  • for anyone who is also trying to pass an enum as a command parameter here is SO post including several variations of the solution. Commented Aug 16, 2014 at 20:24

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.