Hello. I am trying to create a listbox with icons in the first column. These icons have already been defined as resources contained in a resource dictionary. When I do this manually it shows an icon correctly..
What I'm trying to do is change the fill of the rectangle to a resource in the datatemplate to match the content from the database. (So if I added another record the icon could be
a blue circle, for example)
Can someone tell me how to bind the dynamic resource name to a property to the object in the listbox's items collection? Thanks in advance!
The itemssource for this listbox is using linq:
DimdbAsNewDataClassesDataContext
lstSelect.ItemsSource = db.Components
My XAML for the listbox is:
<ListBoxx:Name="lstSelect"HorizontalAlignment="Left"Height="213"Margin="10,36,0,0"VerticalAlignment="Top"Width="257">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanelOrientation="Horizontal">
<RectangleName="ComponentIcon"Height="20"Width="20"Fill="{DynamicResourceFeatureIcon}"/>
<TextBlockName="ComponentName"Text="{BindingPath=Name}"Margin="10,0,0,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>