private void AddSelectedImage(ImagesPicker picker) { if (picker.SelectedImage != null && picker.ImagesPickMode == ImagesPickerMode.Single && (picker.ImagesCollection == null || !picker.ImagesCollection.Contains(picker.SelectedImage))) { picker.addButton.Click -= picker.OnAddButtonClick; picker.addButton.Visibility = System.Windows.Visibility.Collapsed; picker.ImagesCollection = new List <BitmapImage>(); picker.items = new Collection <ImagePickerItem>(); picker.ImagesCollection.Add(picker.SelectedImage); picker.items.Add(new ImagePickerItem() { Image = picker.SelectedImage, RemoveCommand = new RelayCommand <ImagePickerItem>(picker.OnRemoveButtonClick) }); picker.itemsControl.ItemsSource = null; picker.itemsControl.ItemsSource = picker.items; } }
private static void OnSelectedImageChenged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ImagesPicker picker = (ImagesPicker)sender; if (picker.wasAplpyTemplate) { picker.AddSelectedImage(picker); } else { picker.isSelectedImageChanged = true; } if (picker.SelectedImageChanged != null) { picker.SelectedImageChanged.Invoke(picker, new EventArgs()); } }
private void AddSelectedImage(ImagesPicker picker) { if (picker.SelectedImage != null && picker.ImagesPickMode == ImagesPickerMode.Single && (picker.ImagesCollection == null || !picker.ImagesCollection.Contains(picker.SelectedImage))) { picker.addButton.Click -= picker.OnAddButtonClick; picker.addButton.Visibility = System.Windows.Visibility.Collapsed; picker.ImagesCollection = new List<BitmapImage>(); picker.items = new Collection<ImagePickerItem>(); picker.ImagesCollection.Add(picker.SelectedImage); picker.items.Add(new ImagePickerItem() { Image = picker.SelectedImage, RemoveCommand = new RelayCommand<ImagePickerItem>(picker.OnRemoveButtonClick) }); picker.itemsControl.ItemsSource = null; picker.itemsControl.ItemsSource = picker.items; } }