[UWP] Images - when the uwp app suspends and resumes again the image source should be reupdated as uwp replaces images with transparent images onResume (#10161) fixes #8783 fixes #9249 fixes #10168
* #8783 - uwp - images - when the uwp app suspends and resumes again the image source should be reupdated as uwp replaces images with transparent images onResume * #8783 - uwp - OnResume - The toolbar items and their images should be visible after resuming the uwp app
This commit is contained in:
Родитель
9f6697c769
Коммит
e534f11e95
|
@ -14,6 +14,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
public ImageRenderer() : base()
|
||||
{
|
||||
ImageElementManager.Init(this);
|
||||
Windows.UI.Xaml.Application.Current.Resuming += OnResumingAsync;
|
||||
}
|
||||
|
||||
bool IImageVisualElementRenderer.IsDisposed => _disposed;
|
||||
|
@ -44,6 +45,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
{
|
||||
Control.ImageOpened -= OnImageOpened;
|
||||
Control.ImageFailed -= OnImageFailed;
|
||||
Windows.UI.Xaml.Application.Current.Resuming -= OnResumingAsync;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +121,20 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
await ImageElementManager.UpdateSource(this).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
async void OnResumingAsync(object sender, object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ImageElementManager.UpdateSource(this);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Update image source after app resume",
|
||||
$"ImageSource failed to update after app resume: {exception.Message}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void IImageVisualElementRenderer.SetImage(Windows.UI.Xaml.Media.ImageSource image)
|
||||
{
|
||||
Control.Source = image;
|
||||
|
|
|
@ -103,6 +103,21 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
InitializeStatusBar();
|
||||
|
||||
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
|
||||
Windows.UI.Xaml.Application.Current.Resuming += OnResumingAsync;
|
||||
}
|
||||
|
||||
async void OnResumingAsync(object sender, object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UpdateToolbarItems();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Update toolbar items after app resume",
|
||||
$"UpdateToolbarItems failed after app resume: {exception.Message}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetPage(Page newRoot)
|
||||
|
|
Загрузка…
Ссылка в новой задаче