ContentView inherits from the wrong base Layout class
See original GitHub issueDescription
There are two parallel layout implementations in .NET MAUI:
- The new layout implementation with the base class of
Microsoft.Maui.Controls.Layout
- The legacy layout implementation from Xamarin.Forms with the base class of
Microsoft.Maui.Controls.Compatibility.Layout
The new layout implementation is compatible with the new MAUI handlers. The old layout implementation from Xamarin.Forms is not compatible with the handlers and should be avoided.
The problem with the ContentView
is that it has a handler, but is still inherits from the legacy layout Microsoft.Maui.Controls.Compatibility.Layout
. This is a major source of bugs, as the usual layout logic might not be executed correctly or might not get executed at all on some platforms.
Steps to Reproduce
Download and run the attached sample project on Windows.
The sample project contains a single CustomView
inheriting from ContentView
. The sole purpose of that CustomView
is to override all the virtual Measure
, Arrange
, Layout
etc. methods of the base class and dump some debug output when they are called. The sample applications has two additional buttons to call the InvalidateMeasure
method on the CustomView
from the base VisualElement
class and from the IView
interface.
Observe the debug output of the application. You can also put breakpoints in the overridden methods to be sure. Notice that nothing happens: nothing is called at all. All the layout logic of the CustomView
is completely discarded.
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
N/A
Did you find any workaround?
Unless Microsoft changes the implementation of the ContentView
to inherit from the new Microsoft.Maui.Controls.Layut
and implements the necessary glue code, I cannot suggest any viable workaround, except not using ContentView
or any templated controls in the .NET MAUI applications.
Relevant log output
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Wouldn’t this be an issue with the Telerik controls you’re using? I’m not sure how this is a MAUI issue.