Reputation: 429
I have a strange issue with WPF, I was loading images from the disk at runtime and adding them to a Canvas container. My Image size is more than 20MB. I need to display 20 to 30 images in one window and I want to display images in full clearity. My Problem is some images are not displayed. Here below my code
for (var i = 0; i < Count; i++)
{
BitmapImage bmp=new BitmapImage(new Uri(ImagePath, UriKind.RelativeOrAbsolute));
Image imageControl = new Image();
imageControl.Source = bmp;
MyCanvas.Children.Add(imageControl);
}
Upvotes: 1
Views: 60
Reputation: 26
<ItemsControl x:Name="imageLists">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}" Width="500" Margin="15"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Set the ItemsSource of the ItemsControl like this:
imageLists.ItemsSource = Directory.EnumerateFiles(FOLDERPATH, "*.*");
Upvotes: 1