Last active
August 3, 2021 07:10
-
-
Save jasondown/eefde7db49303a357bfab9028cbc7e93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private SmartObservableCollection<ImageViewModel> _images; | |
/// <summary> | |
/// Gets or sets the image collection. | |
/// </summary> | |
/// <value> | |
/// The image collection. | |
/// </value> | |
public SmartObservableCollection<ImageViewModel> Images | |
{ | |
get | |
{ | |
if (_images == null) | |
{ | |
_images = new SmartObservableCollection<ImageViewModel>(); | |
_images.CollectionChanged += (s, e) => OnPropertyChanged(); | |
} | |
return _images; | |
} | |
set | |
{ | |
if (_images != value) | |
{ | |
_images = value; | |
OnPropertyChanged(); | |
InitPageableImages(); | |
} | |
} | |
} | |
private IImageRepository _repository; | |
/// <summary> | |
/// Sets the image repository. | |
/// </summary> | |
/// <param name="repository">The repository.</param> | |
public void SetImageRepository(IImageRepository repository) | |
{ | |
_repository = repository; | |
Images = new SmartObservableCollection<ImageViewModel>(); | |
var imageList = _repository.GetImages(); | |
if (imageList == null) | |
{ | |
UseDefaultImage(); | |
return; | |
} | |
foreach (var image in imageList) | |
{ | |
Images.Add(new ImageViewModel(image)); | |
} | |
if (_images.Count > 0) | |
{ | |
InitPageableImages(); | |
MainImageSource = new BitmapImage(new Uri(PageableImages[0].ItemImage.Source.ToString())); | |
} | |
else | |
{ | |
UseDefaultImage(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment