Width and Height value of ContentPage not filled
See original GitHub issueDescription
The Width and Height property of the ContentPage do not update. They remain -1 and -1.
P. S.: I don’t know which MAUI version I am using. I have the VS2022 version 17.2.0 Preview installed.
Steps to Reproduce
- Add the following code to the MainPage.xaml:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp2.MainPage"
BackgroundColor="{DynamicResource SecondaryColor}"
x:Name="cp">
<Grid x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<Label Grid.Row="1" x:Name="label1"></Label>
<Label Grid.Row="2" x:Name="label2"></Label>
<Button Grid.Row="3" Text="Refresh" Clicked="RefreshNumbers"></Button>
</Grid>
</ContentPage>
- Add the following code to the Mainpage.xaml.cs
namespace MauiApp2;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public void RefreshNumbers(object sender, EventArgs args)
{
label1.Text = "The size of the ContentPage is:\nWidth:" + cp.Width + " Height: " + cp.Height;
label2.Text = "The size of the Grid is:\nWidth:" + grid.Width + " Height: " + grid.Height;
}
}
- Compile and press the button. The values of the Grid layout will update, but the ContentPage will show -1 and -1.
Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
Windows 10 (OS build 19044.1526), Android 11
Did you find any workaround?
No
Relevant log output
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Width of contentview change of size, even when a value is ...
A column given the width * will take the space that is available. ... width to 30% ( .3 ). The height of...
Read more >VerticalStackLayout - .NET MAUI
In a VerticalStackLayout, child views expand to fill the available width when their size isn't explicitly set.
Read more >App crash ContentPage with RadAutoComplete
Setting the width to RadAutoComplete did the trick. now it works perfectly. WidthRequest="100". But setting it like this throws same error,.
Read more >Xamarin Forms LayoutOption Differences
Fill – expands to all the available space inside the parent view. AndExpand – tells the View to expand to the full width...
Read more >Item Size Customization in Xamarin ListView (SfListView)
ItemType: Identifies the item type of the queried item. Handled: Decides whether the specified size can be set to the item or not....
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
This should be fixed in the next preview release
This looks just as I expected! Thank you 😃