Skip to content

Commit 2a6e814

Browse files
author
Mike Corsaro
committed
Use GetImageSourceSize
1 parent 5c7130a commit 2a6e814

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Core/src/Platform/Windows/ButtonExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ public static void UpdateImageSource(this Button platformButton, WImageSource? n
168168
// to the desired size of the font, otherwise it will be stretched to the available space
169169
if (nativeImage.Source is CanvasImageSource canvas)
170170
{
171-
nativeImage.Width = canvas.Size.Width;
172-
nativeImage.Height = canvas.Size.Height;
171+
var size = canvas.GetImageSourceSize(platformButton);
172+
nativeImage.Width = size.Width;
173+
nativeImage.Height = size.Height;
173174
}
174175

175176
// Ensure that we only scale images down and never up
@@ -183,7 +184,7 @@ void OnImageOpened(object sender, RoutedEventArgs e)
183184
var actualImageSource = sender as BitmapImage;
184185
if (actualImageSource is not null)
185186
{
186-
nativeImage.MaxHeight = actualImageSource.PixelHeight;
187+
nativeImage.MaxHeight = nativeImageSource.GetImageSourceSize(platformButton).Height;
187188
}
188189
}
189190
}

0 commit comments

Comments
 (0)