开发者

WPF Binding Enum to Command Parameters

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 MyCom开发者_Python百科mand}" 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜