зеркало из https://github.com/mono/SkiaSharp.git
fix: XamlRoot may be null when the SKXamlCanvas is unloaded (#2854)
* fix: XamlRoot may be null when the SKXamlCanvas is unloaded * chore: Adjust more xamlroot uses --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
This commit is contained in:
Родитель
258a6f62bd
Коммит
8e7a51dc04
|
@ -101,7 +101,7 @@ namespace SkiaSharp.Views.UWP
|
||||||
private void OnXamlRootChanged(XamlRoot xamlRoot = null, XamlRootChangedEventArgs e = null)
|
private void OnXamlRootChanged(XamlRoot xamlRoot = null, XamlRootChangedEventArgs e = null)
|
||||||
{
|
{
|
||||||
var root = xamlRoot ?? XamlRoot;
|
var root = xamlRoot ?? XamlRoot;
|
||||||
Dpi = root.RasterizationScale;
|
Dpi = root?.RasterizationScale ?? 1.0;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -141,7 +141,10 @@ namespace SkiaSharp.Views.UWP
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
|
if(XamlRoot != null)
|
||||||
|
{
|
||||||
XamlRoot.Changed -= OnXamlRootChanged;
|
XamlRoot.Changed -= OnXamlRootChanged;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
var display = DisplayInformation.GetForCurrentView();
|
var display = DisplayInformation.GetForCurrentView();
|
||||||
display.DpiChanged -= OnDpiChanged;
|
display.DpiChanged -= OnDpiChanged;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче