I need to display an information icon for some ListBox items.
The icon is defined as a ViewBox in the application resourses and I use DataTemplate as ListBox ItemTemplate.
<Viewbox x:Key="InformationSymbol" Width="16" Height="16"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Canvas Width="16" Height="16">
<Path Fill="#00FFFFFF" Data="F1M16,16L0,16 0,0 16,0z" />
<Path Fill="#FFF6F6F6" Data="F1M10,14L6,14 6,2 10,2z" />
<Path Fill="#FF424242" Data="F1M9,3L7,3 7,5 9,5z M9,13L7,13 7,6 9,6z" />
</Canvas>
</Viewbox>
<DataTemplate x:Key="MyDataTemplate">
<!--main data here-->
<ContentControl Content="{DynamicResource InformationSymbol}">
<!--visibility trigger here-->
</ContentControl>
</DataTemplate>
<ListBox ItemsSource="{Binding MyList}"
ItemTemplate="{StaticResource MyDataTemplate}"/>
The problem is that the icon is displayed for the last item only.
I've tried replacing {DynamicResource InformationSymbol}
with some static text, e.g. help
and it is displayed for every item correctly. So it's only the icon resource that won't display repeatedly.
How can I make it displayed for several items?
Update
Later on I tried to use the ContentControl by its own (out of the ListBox) several time as shown below and it resulted in only the last one desplayed.
<StackPanel>
<ContentControl Content="{DynamicResource InformationSymbol}"/>
<ContentControl Content="{DynamicResource InformationSymbol}"/>
</StackPanel>