Skip to content

Conversation

@Bober95
Copy link
Contributor

@Bober95 Bober95 commented Dec 17, 2025

In the version currently released on NuGet, when animation is disabled, the expander doesn't expand at all.

After a recent fix for the initial expander state (blinking), expansion doesn't work at all (with or without animation).

This fix fixes this issue.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a bug where the expander control fails to expand after recent changes. The fix includes three main modifications: restructuring the event handler registration logic to only initialize state when the animation feature is enabled, adding a conditional check in the event handler to handle cases where animations are disabled, and explicitly setting visibility before animating expansion.

Key Changes

  • Refactored event handler registration to occur outside the IsEnabled check, moving initialization logic inside the conditional block
  • Added IsEnabled check in OnExpanderExpandedOrCollapsed to handle visibility directly when animations are disabled
  • Explicitly set Visibility.Visible before starting expand animation to ensure proper state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +92 to +93
expander.Expanded += OnExpanderExpandedOrCollapsed;
expander.Collapsed += OnExpanderExpandedOrCollapsed;
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event handlers are registered unconditionally regardless of whether IsEnabled is true or false. This means handlers will be attached even when the feature is disabled, and they will be registered multiple times if the property is set repeatedly. This can lead to memory leaks and unexpected behavior. The handlers should only be registered when IsEnabled is true, and should be unregistered when IsEnabled changes to false.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

…sHelper.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@NotYoojun NotYoojun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently an Expander with IsExpanded="True" in XAML will throw an exception:

<Expander Style="{StaticResource {x:Static ui:ThemeKeys.ExpanderCardStyleKey}}" Header="Welcome" HorizontalAlignment="Stretch" IsExpanded="True">
    <Expander.Content>
        <Grid HorizontalAlignment="Stretch" Background="Red">
            <TextBlock HorizontalAlignment="Right">Test</TextBlock>
        </Grid>
    </Expander.Content>
</Expander>
Image

Not sure if this is introduced here or originally existing. Perhaps we can merge this after its fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants