maui
maui copied to clipboard
Wrap Image with a container on Windows so that it is centered with AspectFill
Description of Change
On Windows, we use Microsoft.UI.Xaml.Controls.Image which has a stretch property. When this property is set in WinUI, the image will not be centered. According to the WinUI team, this is intended behavior:
As you can see in the screenshot above, one workaround we can utilize is to wrap the image in a Grid
. Luckily, we can utilize the existing WrapperView on Windows by adding a ContainerView
to the Windows ImageHandler
.
Before
After
Issues Fixed
Fixes #10645
Copied from https://github.com/dotnet/maui/pull/15122
Depends on
- [ ] https://github.com/dotnet/maui/pull/17918
/rebase
For now let's just merge this without the updated extensions. And we can just fix those in post
/rebase
@japarson Could you please resolve conflicts and add a UI test? Thanks!
/rebase
@japarson Could you please resolve conflicts and add a UI test? Thanks!
@Foda Test is added and conflicts are resolved.
/azp run
Azure Pipelines successfully started running 3 pipeline(s).