Reputation: 81
I am having few images in a list
public List<Image> UniqueDeviceImages
{
get;
set;
}
I am trying to bind these set of images to a treeview
<StackPanel Orientation="Horizontal">
<ItemsControl x:Name="ImagelistControl" ItemsSource="{Binding Path=UniqueDeviceImages}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Path=UniqueDeviceImages,Converter={StaticResource bitmapconvertor }}" Height="15" Width="15" Margin="0,2,4,3"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding Path= UniqueDeviceName}">
</TextBlock>
</StackPanel>
There is a bitmap convertor which converts Image to Imageresource type. The images are not getting binded to the treeview. The treeview just shows the device name. It does not show any images.
Upvotes: 0
Views: 182
Reputation: 128181
The DataContext of an item container in an ItemsControl is automatically set to the appropriate data item from the ItemsSource
collection. Hence in your DataTemplate you must not bind again to the UniqueDeviceImages
property. Just drop the Path
part of the binding expression:
<Image Source="{Binding Converter={StaticResource bitmapconvertor}}" .../>
Upvotes: 1