Skip to content

Instantly share code, notes, and snippets.

@jasondown
Last active August 3, 2021 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasondown/eefde7db49303a357bfab9028cbc7e93 to your computer and use it in GitHub Desktop.
Save jasondown/eefde7db49303a357bfab9028cbc7e93 to your computer and use it in GitHub Desktop.
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