Open amdingler opened 3 years ago
Thought this was resolved in https://github.com/microsoft/microsoft-ui-xaml/pull/4394
I think this is basically a duplicate of https://github.com/microsoft/microsoft-ui-xaml/issues/4407
I think @amdingler is also focusing on naming and the timing of events here. This was all discussed:
To fire events after the animation itself is complete is no simple task. It also would heavily restrict the template itself.
There was also a request to make the events "symmetrical" and have all four: Collapsing, Collapsed, Expanding, Expanded. Bug: Expander Events Naming #4390
The current Collapsed event is misnamed, and it is fired as soon as the expander begins collapsing.
The code fires the event AFTER the visual state is applied here. In-code sequence is correct and was double checked.
The concern about animation continuing after collapsed is fired was noted as mentioned in the above comment. However, there is no correct fix for this. Can you name any other control that waits for an animation which is part of the style to complete before it fires a fundamental event? I don't believe even AnimatedVisualPlayer
or AnimatedIcon
have such events. In fact doing so breaks the lookless control concept of separation between logic and style. Logic starts to depend directly on style and the code-behind has to get pretty invasive to manage things correctly. Restyling is very difficult at that point.
If it is very important for your app, I do believe the animation times are fixed. You could add a delay of N milliseconds after receiving the Collapsed event to be sure the animation is complete.
Edit: I double checked WPF which also appears to behave the same way.
Note that if adding a delay on the assumption that there will be animations, need to allow for animations being disabled in the system-wide accessibility settings
@ranjeshj FYI
Proposal: Collapsed/Expanded Event for Expander Control
Summary
It would be great to be able to access an event to perform an action once the Expander control has completely collapsed or expanded.
Rationale
Important Notes
The current Collapsed event is misnamed, and it is fired as soon as the expander begins collapsing.