Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise the EffectiveViewPortChanged when a control is added to the tree that has already has a valid layout #17570

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

danwalmsley
Copy link
Member

What does the pull request do?

Fix the raising of the EffectiveViewPortChanged event.

What is the current behavior?

If you add a control that expects the EffectiveViewPortChanged event to a tree that has already has a valid layout, it never receives the event, giving the initial value.

The reason is because when the listener is added

new EffectiveViewportChangedListener(
control,
CalculateEffectiveViewport(control));

    an initial value is calculated for the viewport.

When this is being added to a parent that has a size a size here is calculated.

Now when the actual layout pass happens

LayoutManager -> RaiseEffectiveViewportChanged()

var viewport = CalculateEffectiveViewport(l.Listener);

if (viewport != l.Viewport)
{
    l.Listener.RaiseEffectiveViewportChanged(new EffectiveViewportChangedEventArgs(viewport));
    l.Viewport = viewport;
}

viewport and l.Viewport are equal and the event is skipped.

What is the updated/expected behavior with this PR?

We now match the UWP behavior of raising the event.

How was the solution implemented (if it's not obvious)?

  1. don't initialise the Listener ViewPort property.
  2. make the Listener ViewPort property nullable, so that it has to raise it the first time.

This other PR updates the UWP tests that prove our behaviour is the same.
grokys/EffectiveBoundsTestsUWP#1

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@danwalmsley danwalmsley added backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch bug labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant