Add ExpanderAnimationBehavior, IExpansionController#3124
Open
stephenquan wants to merge 10 commits intoCommunityToolkit:mainfrom
Open
Add ExpanderAnimationBehavior, IExpansionController#3124stephenquan wants to merge 10 commits intoCommunityToolkit:mainfrom
stephenquan wants to merge 10 commits intoCommunityToolkit:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a pluggable expansion/collapse pipeline to Expander to enable animated transitions via an IExpansionController, plus a default animation behavior and updated samples demonstrating the new functionality.
Changes:
- Introduces
IExpansionControllerand wiresExpander.ExpansionControllerinto the expand/collapse flow. - Adds
ExpandedChanging+ExpandedChangingEventArgs, and refactorsExpandercontent handling to use aContentHostcontainer suitable for animation. - Adds
ExpanderAnimationBehaviorimplementingIExpansionController, and updates the sample page to demonstrate animation timing.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs | Adds controller-based expand/collapse pipeline, new event, and ContentHost wrapper used for animation. |
| src/CommunityToolkit.Maui/Interfaces/IExpansionController.shared.cs | New interface to plug in animated (or instant) expand/collapse implementations. |
| src/CommunityToolkit.Maui/Behaviors/ExpanderAnimationBehavior.shared.cs | New behavior implementing IExpansionController using Animation to animate expansion/collapse. |
| src/CommunityToolkit.Maui.Core/Primitives/ExpandedChangingEventArgs.shared.cs | New event args for “about to change expanded state”. |
| src/CommunityToolkit.Maui.Core/Primitives/Defaults/ExpanderAnimationBehaviorDefaults.shared.cs | Defaults for easing/duration used by ExpanderAnimationBehavior. |
| samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs | Measures elapsed time between ExpandedChanging and ExpandedChanged and shows it in a toast. |
| samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml | Applies ExpanderAnimationBehavior in samples and hooks ExpandedChanging/ExpandedChanged handlers. |
src/CommunityToolkit.Maui/Behaviors/ExpanderAnimationBehavior.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/ExpanderAnimationBehavior.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/ExpanderAnimationBehavior.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Views/Expander/ExpanderTests.cs
Outdated
Show resolved
Hide resolved
samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
Outdated
Show resolved
Hide resolved
samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml
Show resolved
Hide resolved
pictos
reviewed
Mar 2, 2026
samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
Outdated
Show resolved
Hide resolved
samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/ExpanderAnimationBehavior.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/ExpanderAnimationBehavior.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Views/Expander/ExpanderTests.cs
Outdated
Show resolved
Hide resolved
pictos
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…EventArgs
Description of Change
Enables animated expand/collapse behavior for the
Expanderby wrapping the user’s contentExpander.Contentin aExpander.ContentHost(ContentView) and animating changes toExpander.ContentHost.HeightRequest.Expander.ContentHostproperty (read-only).IExpansionControllerinterface.Expander.ExpansionControllerproperty.Expander.ExpandedChangingevent withExpandedChangingEventArgs.ExpansionAnimationBehaviorbehavior.ExpandedAnimationBehavior.Opt in to animations by assigning
ExpansionAnimationBehaviorto either (1)Expander.Behaviors, or (2)Expander.ExpansionController. Alternatively, custom animations can be created by implementingIExpansionController.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
This is a reboot of the work that began in PR #2723 and PR #2522.