I have the following XAML code:
<ListBox ItemsSource="{Binding Languages}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding LanguageIcon}" />
<Label Content="{Binding LanguageName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
and in the model class:
class Language {
public string LanguageName;
public ImageSource LanguageIcon;
}
my modelview class contains:
public List<Language> Languages;
which is filled in:
Languages.Add(new Language("A",new BitmapImage(new Uri("Resources/a.ico",
UriKind.Relative))));
Languages.Add(new Language("B",new BitmapImage(new Uri("Resources/b.ico",
UriKind.Relative))));
When I start the project, all the names of my languages are displayed in the list, but not the icons ... Why is this happening and how can I make sure that my icons are displayed? (I am sure that resources exist because BitmapImages do not generate errors)
source
share