Skip to content

Proposal: Add the Ability to Cancel Expand/Collapse of the Expander #4407

@robloo

Description

@robloo

Proposal: Add the Ability to Cancel Expand/Collapse of the Expander

Summary

In some cases it is necessary to programmatically override user selection and cancel either expanding or collapsing the Expander control (specific case described below).

In order to support this, the following Events/Properties should be added:

/// <summary>
/// Gets or sets a value indicating whether the expander is pinned to its current state (either expanded or collapsed).
/// The toggle button to change state will be disabled.
/// </<summary>
bool IsPinned;

/// <summary>
/// Event fired before the control is expanded.
/// This allows cancelling the expand operation.
/// </summary>
event TypedEventHandler<Expander, ExpanderExpandingEventArgs> Expanding;

/// <summary>
/// Event fired before the control is collapsed.
/// This allows cancelling the collapse operation.
/// </summary>
event TypedEventHandler<Expander, ExpanderCollapsingEventArgs> Collapsing;

Cancellation and the Expanding/Collapsing events should follow what is done in Flyout and FlyoutBaseClosingEventArgs.

Rationale

This functionality is needed, for example, in the following use-case:

When there are many properties in an editor it is common to group them and put them in an accordion-style layout with Expanders stacked on top of one another. In my case, to save space, only one Expander should be opened at a time in the accordion. However, at least one expander should always be opened to show something to the user.

The closing event with cancelation is necessary to ensure the currently expanded expander in the accordion is never closed. It is only closed when another expander is expanded.

Further discussed: #4390 (comment) and #3279 (comment)

Scope

Capability Priority
Expanding event Must
Collapsing event Must
IsPinned Should

Important Notes

Also see:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions