I get this quite infuriating error a lot in converting a Xamarin app. Typically the exception is not raised until the UI is updated, but the problem actually happened much earlier and somehow had been 'remembered' by MAUI meanwhile! An example is a static list of visual elements that is added to a StackLayout on multiple occasions. The parent of each visual element must then be removed before adding the visual element. Can be tedious to find, in a complex app.
Maui tells me I have a problem but surely it could narrow it down
In my Maui app, I get the message:
[0:] Microsoft.Maui.Controls.Element: Warning: Microsoft.Maui.Controls.Label is already a child of Microsoft.Maui.Controls.Grid. Remove Microsoft.Maui.Controls.Label from Microsoft.Maui.Controls.Grid before adding to Microsoft.Maui.Controls.Grid.
Java.Lang.IllegalStateException: 'The specified child already has a parent. You must call removeView() on the child's parent first.'
If the compiler can tell me there is a problem with a Grid and a Label, surely it can tell me the name of the Grid and the Label, or a line number or something to help me find the source of the problem. I think this is a bug in the compiler - a serious short coming.
How else can I find the Grid and Label responsible for this issue?
Thanks