Open Youssef1313 opened 1 month ago
@ramezgerges Could it be a regression from recent ContentPresenter changes?
I couldn't reproduce this on my machine (on Windows with latest master).
@MartinZikmund Can you check if you can repro or if it's just me somehow? :/
I have tested this by adding the snippet above in Given_ContentControl.cs
(you can even just keep the [DataRow(ContentPresenter)]
, others are not needed) and indeed it stack overflows for me on Skia.Generic and on UnoIslandsSamplesApp.Skia.Wpf. Based on my debugging the problem is as follows:
ContentPresenter
is constructedOnApplyTemplate
is calledContent
is created - binding to ContentControl.Content
of the TemplatedParent
of the ContentPresenter
TemplatedParent
is assumed to be SampleControl
- which applies its content (UnitTestsPage
) as the Content
of the tested ContentPresenter
- thus creating a circular visual tree where the parent of the page is the grand child ContentPresenter
I assume the problem that needs to be fixed here is the fact that TemplatedParent
of the ContentPresenter
should just be null
, as it is actually not part of a template. Adding @ramezgerges and @Xiaoy312
Let's wait for Xiao's work then.
To debug this most easily, adjust the SetParent
method in src\Uno.UI\UI\Xaml\DependencyObjectExtensions.cs
as follows:
You will be able to see that this gets executed for UnitTestsPage
once when it is first opened, and then the second time after the unit test starts - setting the page's Parent
to be its grand child ContentPresenter
Current behavior
When the following test executes for ContentPresenter, it stackoverflows :(
Expected behavior
No response
How to reproduce it (as minimally and precisely as possible)
No response
Workaround
No response
Works on UWP/WinUI
None
Environment
No response
NuGet package version(s)
No response
Affected platforms
No response
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response