in PhotoEditor/MainPage.cpp [70:118]
IAsyncAction MainPage::OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
{
auto elementVisual = ElementCompositionPreview::GetElementVisual(args.ItemContainer());
auto image = args.ItemContainer().ContentTemplateRoot().as<Image>();
if (args.InRecycleQueue())
{
elementVisual.ImplicitAnimations(nullptr);
image.Source(nullptr);
}
if (args.Phase() == 0)
{
//Add implicit animation to each visual.
elementVisual.ImplicitAnimations(m_elementImplicitAnimation);
args.RegisterUpdateCallback([&](auto sender, auto args)
{
OnContainerContentChanging(sender, args);
});
args.Handled(true);
}
if (args.Phase() == 1)
{
// It's phase 1, so show this item's image.
image.Opacity(100);
auto item = unbox_value<PhotoEditor::Photo>(args.Item());
Photo* impleType = get_self<Photo>(item);
try
{
auto thumbnail = co_await impleType->GetImageThumbnailAsync();
image.Source(thumbnail);
}
catch (winrt::hresult_error)
{
// File could be corrupt, or it might have an image file
// extension, but not really be an image file.
BitmapImage bitmapImage{};
Uri uri{ image.BaseUri().AbsoluteUri(), L"Assets/StoreLogo.png" };
bitmapImage.UriSource(uri);
image.Source(bitmapImage);
}
}
}