fix: image viewer crash issue.

This commit is contained in:
NaBian committed 2024-03-06 14:33:35 +08:00
1 parent 0e4e7c9293
commit 66ad32f52a
1 file changed
+3 -4
@@ -962,11 +962,10 @@ public class ImageViewer : Control
private void OnUriChanged(Uri newValue) private void OnUriChanged(Uri newValue)
{ {
if (newValue is not null) ImageSource = newValue is not null ? GetBitmapFrame(newValue) : null;
if (ImageSource is not null && newValue.IsAbsoluteUri)
{ {
ImageSource = GetBitmapFrame(newValue);
ImgPath = newValue.AbsolutePath; ImgPath = newValue.AbsolutePath;
if (File.Exists(ImgPath)) if (File.Exists(ImgPath))
{ {
ImgSize = new FileInfo(ImgPath).Length; ImgSize = new FileInfo(ImgPath).Length;
@@ -974,8 +973,8 @@ public class ImageViewer : Control
} }
else else
{ {
ImageSource = null;
ImgPath = string.Empty; ImgPath = string.Empty;
ImgSize = 0;
} }
static BitmapFrame GetBitmapFrame(Uri source) static BitmapFrame GetBitmapFrame(Uri source)