In my XAML
I have:
<Window.Resources>
<DataTemplate x:Key="CastTemplate">
<DockPanel Width="Auto">
<Image Source="{Binding image}" Width="10" Height="10"/>
<TextBlock Text="{Binding name}"/>
<TextBlock Text="{Binding character}"/>
</DockPanel>
</DataTemplate>
<Window.Resources>
<Grid HorizontalAlignment="Center">
<ItemsControl ItemTemplate="{StaticResource CastTemplate}" ItemsSource="{Binding SelectedItem.castInfoWithPics}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="3" Rows="2"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
The binding
points to a list of objects with the following properties:
public string name { get; set; }
public string character { get; set; }
public BitmapSource image { get; set; }
In my ViewModel
, I assign the image
property using:
cast.image = loadBitmap(bitmap);
I am using the loadBitmap
function stated here: https://stackoverflow.com/a/1118557/2268507
The problem I'm having is that the image
is not being displayed when I run my program. The name
and character
properties appear however.
I also don't seem to be receiving any Binding
errors. Would anyone know what the issue might be?