user1017882
user1017882

Reputation:

Bind enum value to label in data template

<Label Content="{Binding ActivityName}" Foreground="Black"></Label>
<Label Content="{Binding ActivityType}" Foreground="Black"></Label>

When I bind a list of Activity's to this DataTemplate, I can see the ActivityName (a String property) displayed in the Label fine. The ActivityType, however, is an enum, and this doesn't bind to the Label at all. I'm assuming I need to call some sort of toString() on the enum but I don't have a clue how to do it in XAML.

Thanks.

Upvotes: 1

Views: 1845

Answers (1)

sll
sll

Reputation: 62494

Try out

<Label Content="{Binding ActivityType,StringFormat={}{0}}" />

Upvotes: 3

Related Questions