-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[TransitioningContentControl] Manage his LogicalChildren #12173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You can test this PR using the following package version. |
You can test this PR using the following package version. |
Nice one!
I think it would be nice to have debug warnings in the future when a logical child is added to a parent while it already has one. Even if there are valid use cases for this (as discussed with grokys previously in #10413), it could help catching this kind of problem sooner. |
You can test this PR using the following package version. |
Can confirm it works! 👍 The |
Then when we override it in the inheriting class without implementing anything, it won't be so clear why. I thought that way it would be clearer. |
A simple comment could work. Alternatively, |
IMO it doesn't look aesthetic, but you decide.
Oh, this is a bad idea IMO, for two reasons:
|
I think there's a misunderstanding here, I was definitely not advocating on never calling the Not calling the base was only for
( |
Got it, so what's better? Edit: On second thought it still sounds like a bad idea to me. Consider the following case:
The code in Class1 will not be executed, we just wanted to skip on the Class2 code. |
Yes, that's a general problems with overrides and I agree it can be a pain when you're class 3 and need to repeat a behavior from class 1 that have been inhibited by class 2. Unfortunately C# doesn't allow calling an arbitrary ancestor's virtual method non-virtually (it's possible in IL). In this particular case, the To me it's a win as it avoids defining a specific public flag that will only be used by |
@MrJul No matter, It's done, can it be merged now? |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
What does the pull request do?
There are two problems with
TransitioningContentControl
:ContentPresenter
manages his host'sLogicalChildren
(in this case TCC), and in additionContentControl
also managesLogicalChildren
, which causes logical children to be duplicated.ContentPresenter
not register the TCC as its Host, which causes it to not manage theLogicalChildren
of the TCC.We need to decide who will manage the logical children, CC (ContentControl) or TCC, in this case it is clear that TCC should do it, because CC is only adapted to one child, whereas TCC can have two (during animation).
The implementation was carried out by adding asee comment below.BypassLogicalChildrenManagement
property to the CC that allows the controls inheriting from it to manage theLogicalChildren
themselves, in this case, TCC does not need to do anything, his presenters do it for him.The second problem is a bug in the
RegisterContentPresenter
implementation that returnedfalse
even if Presenter isPART_ContentPresenter
, which causes the Host registration to be skipped:Avalonia/src/Avalonia.Controls/Presenters/ContentPresenter.cs
Lines 702 to 706 in 124f124
The fixes is pretty obvious.
Checklist
Breaking changes
No.
Fixed issues
Fixes #12158