ContentView's OnSizeAllocated method will loaded before controls init in xaml
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
Today i create a ContentView, i want get control size at OnSizeAllocated, but when app first time load OnSizeAllocated, control is null. I try to do this at ContentPage, OnSizeAllocated will get correct control, so i feel it is a bug.
### Steps to Reproduce
1. Create a Maui app project.
2. Create a ContentView and add it to MainPage, and create OnSizeAllocated method, create control in xaml, and use control in OnSizeAllocated method.
3. set break point in OnSizeAllocated method,then run
### Version with bug
6.0 (current)
### Last version that worked well
Release Candidate 3 (current)
### Affected platforms
Windows, I was *not* able test on other platforms
### Affected platform versions
Windows SDK 10.0.22000.194
### Did you find any workaround?
_No response_
### Relevant log output
_No response_
Contributor guide
Research direction
Reproduce the issue in a .NET MAUI app on Windows using a ContentView added to MainPage, with a XAML control accessed from OnSizeAllocated. Compare the ContentView callback with ContentPage behavior and trace the control-initialization lifecycle; done means the callback no longer exposes an uninitialized control, or the expected lifecycle behavior is clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100