Skip to content

Bug: Expander Events Naming #4390

Closed

Description

I noticed that expander has two events: Expanding and Collapsed that are named differently.

event Windows.Foundation.TypedEventHandler<Expander, ExpanderExpandingEventArgs> Expanding;
event Windows.Foundation.TypedEventHandler<Expander, ExpanderCollapsedEventArgs> Collapsed;

Expanding implies the event is fired before the control is expanded and Collapsed implies after. Therefore, a difference in naming here concerned me so I went to check the code. Sure enough, there seems to be a mismatch. According to the code below all events are fired BEFORE the is expanded state is applied meaning both events should be named with a 'ing' suffix. Is my understanding correct here? If so this is actually a bug.

void Expander::OnIsExpandedPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& /*args*/)
{
if (IsExpanded())
{
RaiseExpandingEvent(*this);
}
else
{
RaiseCollapsedEvent(*this);
}
UpdateExpandState(true);
}

The differences in naming is actually quite important as in the future four events should be added to cancel expanding/collapsing. #3279 (comment). There should be four total events in the end:

  1. Expanding <- Can cancel
  2. Expanded
  3. Collapsing <- Can cancel
  4. Collapsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions