I have an List values with a ResourceKey and a Caption, these values are both strings. The Resource is the name of an actual resource defined in a resource dictionary. Each of these ResourceKey Icons are Canvas’s.
<Data ResourceKey='IconCalendar' Caption='Calendar'/> <Data ResourceKey='IconEmail' Caption='Email'/>
I then have a list view which has a datatemplate with a button and a text caption below the button. What I want to do is display Resource static resource as the content for the button.
<ListView.ItemTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height='*' /> <RowDefinition Height='Auto' /> </Grid.RowDefinitions> <Button Content='{Binding ResourceKey}' Template='{StaticResource RoundButtonControlTemplate}'/> <TextBlock Grid.Row='1' Margin='0,10,0,0' Text='{Binding Caption}' HorizontalAlignment='Center' FontSize='20' FontWeight='Bold' /> </Grid> </DataTemplate> </ListView.ItemTemplate>
I think I have tried every permutation with binding staticresource etc.
I am open to alternatives, I know it may be easier to just have an image and set the source property.
Thanks
After having a little think I ending up using a
ValueConvertorlike so:and the binding on the button becomes