In .Net MAUI a container is wrong resized on iOS, when an image with AspectFit is inside
See original GitHub issueThis issue has been moved from a ticket on Developer Community.
Hi, in .Net MAUI a container is wrong resized on iOS, when an image with AspectFit is inside. I described it with pictures in the word file. You 'll find in the attachments also a sample programm to debug the problem. The error cause, that I can’t update my Xamarin.Forms app to .NET MAUI. Thanks Marian
(full repro attached in internal ticket)
From the Word document:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiAppImages2.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="25" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Grid>
<Image
Source="image1.png"
Aspect="AspectFit"
HorizontalOptions="FillAndExpand"
VerticalOptions="Start"
BackgroundColor="Yellow"/>
<Border HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Stroke="Red" StrokeThickness="4" StrokeShape="RoundRectangle 10,10,10,10" BackgroundColor="Transparent" Margin="0" Padding="0" />
</Grid>
<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Original Comments
Feedback Bot on 3/15/2023, 07:56 PM:
(private comment, text removed)
Original Solutions
(no solutions)
Issue Analytics
- State:
- Created 6 months ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
NET MAUI Image wrong size - xamarin
I made some changes: I tried using data binding in MVVM way. I tried counting image ratio using platform code. The following is...
Read more >Image - .NET MAUI
NET MAUI Image displays an image that can be loaded from a local file, a URI, ... At build time, vector images are...
Read more >Image Scaling in .NET MAUI
The Image control has an Aspect property which allow us to indicate how an image will fit into the display area (scaling). This...
Read more >How to resize an UIImageView to fit a container view using ...
An image view changes its parent frame instead of resizing itself to fit the parent frame. The problem might be hard to understand...
Read more >Sizing an image to the width of screen and keep the ratio?
I've tried aspect fit but it creates white space on the top and bottom. ... The imageview is not resizing, just the image...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi all,
yes I am also experience the same behavior with my images in my current project, so please fix the problem.
Here’s a fundamental workaround. The sizing logic in the
GetDesiredSize
override could be improved, but this works for this case and gives you the place to do whatever you need for sizing.Subclass ImageHandler for iOS, and then register the handler for iOS Image.
Platforms/iOS/SizedImageHandler.cs
MauiProgram.cs