diff --git a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs index 57cddcc39..ed9f59dc0 100644 --- a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs +++ b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs @@ -160,6 +160,8 @@ public class ImageViewer : Control private DispatcherTimer _dispatcher; + private bool _isLoaded; + #endregion Data #region ctor @@ -174,7 +176,11 @@ public ImageViewer() CommandBindings.Add(new CommandBinding(ControlCommands.RotateLeft, ButtonRotateLeft_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.RotateRight, ButtonRotateRight_OnClick)); - Loaded += (s, e) => Init(); + Loaded += (s, e) => + { + _isLoaded = true; + Init(); + }; } /// @@ -445,7 +451,7 @@ private static void OnImageScaleChanged(DependencyObject d, DependencyPropertyCh /// private void Init() { - if (ImageSource == null || !IsLoaded) return; + if (ImageSource == null || !_isLoaded) return; if (ImageSource.IsDownloading) { @@ -464,13 +470,13 @@ private void Init() if (!_isOblique) { - width = ImageSource.Width; - height = ImageSource.Height; + width = ImageSource.PixelWidth; + height = ImageSource.PixelHeight; } else { - width = ImageSource.Height; - height = ImageSource.Width; + width = ImageSource.PixelHeight; + height = ImageSource.PixelWidth; } ImageWidth = width; @@ -514,7 +520,7 @@ private void Dispatcher_Tick(object sender, EventArgs e) { if (_dispatcher == null) return; - if (ImageSource == null || !IsLoaded) + if (ImageSource == null || !_isLoaded) { _dispatcher.Stop(); _dispatcher.Tick -= Dispatcher_Tick;