I am new to WPF.I want to show different images from drive and show it in grid with 2 rows and 3 columns with paging.
I am able to display images in single column using below code
XMAL :
<DatGrid>
<DataGrid.Columns >
<DataGridTemplateColumn Header="SampleImages">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Height="70" Width="70" Source="{Binding}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns></DatGrid>
XMAL.CS
string path = Environment.CurrentDirectory+ "\\snapshot\\";
List<string> imageList = new List<string>();
string[] images = System.IO.Directory.GetFiles(path);
Image image= new Image();
foreach (string Img in images)
{
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(Img, UriKind.Relative);
bmp.EndInit();
image.Source = bmp;
//imageList.Add(new Image { Source = bmp });
imageList.Add(Img);
}
imageDataGrid.ItemsSource = imageList;
Please note these images are generated run time and stored on specified path in code.
But not able to display in 2 rows and 3 columns with pagination.I also want to use MVVM.
Searched alot but not able to get any fruitful results.Can anybody guide me in the same.
Thanks in advance.