fix: fix image binding to stretch initialization issue.
This commit is contained in:
@@ -163,8 +163,9 @@ public class ImageViewer: TemplatedControl
|
|||||||
|
|
||||||
private void OnStretchChanged(AvaloniaPropertyChangedEventArgs args)
|
private void OnStretchChanged(AvaloniaPropertyChangedEventArgs args)
|
||||||
{
|
{
|
||||||
|
if (_image is null) return;
|
||||||
var stretch = args.GetNewValue<Stretch>();
|
var stretch = args.GetNewValue<Stretch>();
|
||||||
Scale = GetScaleRatio(Width / _image!.Width, Height / _image!.Height, stretch);
|
Scale = GetScaleRatio(Width / _image.Width, Height / _image.Height, stretch);
|
||||||
_sourceMinScale = _image is not null ? Math.Min(Width * MinScale / _image.Width, Height * MinScale / _image.Height) : MinScale;
|
_sourceMinScale = _image is not null ? Math.Min(Width * MinScale / _image.Width, Height * MinScale / _image.Height) : MinScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user