Depending on the number of selected pictures, you need to generate a certain number of pictures on the page. What I do: I throw pictures to the list, then I read alternately and throw to another list.ViewModel
private IReadOnlyList<StorageFile> collageimages; private List<CollageModel> imageList; private Thickness temp = new Thickness (50, 50, 0, 0); public ImageManipulatorViewModel() { this.ImageList = new List<CollageModel>(); } public List<CollageModel> ImageList { get { return this.imageList; } set { this.imageList = value; base.RaisePropertyChanged("ImageList"); } } this.collageimages = await OpenPicker.PickMultipleFilesAsync(); for (var i = 0; i < collageimages.Count-1; i++) { var stream = await collageimages[i].OpenAsync(FileAccessMode.Read); var bitmapImage = new WriteableBitmap(100, 100); bitmapImage.SetSource(stream); this.ImageList.Add(new CollageModel() {CollageImage = bitmapImage, Margins = this.temp}); } Model :
public class CollageModel { public Thickness Margins { get; set; } public WriteableBitmap CollageImage { get; set; } } Binding on Xaml :
<UserControl.DataContext> <StaticResource ResourceKey="ImageManipulatorViewModel"/> </UserControl.DataContext> <!--...--> <Canvas Width="Auto" Height="1200" x:Name="MyCanvas" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"> <ItemsControl ItemsSource="{Binding ImageList}"> <ItemsControl.ItemTemplate> <DataTemplate x:DataType="models:CollageModel"> <Image Source="{x:Bind CollageImage}" Margin="{x:Bind Margins}" Height="100" Width="100"> </Image> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> But as a result there is nothing on the form. On debug, it enters the method normally, fills the list
DataContextinstalled? - Donil