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

AttachedDropShadow size changes abnormally #4548

Closed
3 of 14 tasks
chenjt2001 opened this issue May 5, 2022 · 4 comments · Fixed by #4549
Closed
3 of 14 tasks

AttachedDropShadow size changes abnormally #4548

chenjt2001 opened this issue May 5, 2022 · 4 comments · Fixed by #4549
Assignees
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 hotfix 🌶
Milestone

Comments

@chenjt2001
Copy link
Contributor

chenjt2001 commented May 5, 2022

Describe the bug

AttachedDropShadow display problem when the size of the element that owns the AttachedDropShadow changes.

`

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>

    <Border x:Name="ShadowTarget" Grid.Column="0"/>

    <Border Grid.Column="1" Background="AliceBlue">
        <ui:Effects.Shadow>
            <ui:AttachedDropShadow BlurRadius="60"
                               Color="Black"
                               CastTo="{Binding ElementName=ShadowTarget}"/>
        </ui:Effects.Shadow>
    </Border>
</Grid>
`

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

1. Run the Application.
2. Change the window size.

Expected behavior

The shadow remains displayed on the entire edge of the Border.

Screenshots

  1. When the application starts:
    捕获

  2. After resizing the window:
    捕获2
    捕获3

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

Windows 21H2 (19044.1645)

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

17.1.6

Device form factor

Desktop

Nuget packages

Microsoft.NETCore.UniversalWindowsPlatform: 6.2.13
Microsoft.Toolkit.Uwp.UI: 7.1.2

Additional context

If we set the Border's Background to Transparent, we can find that the size of the window changes in time, but the aspect ratio of the shadow remains unchanged. Maybe that's the reason for the problem.

Help us help you

Yes, but only if others can assist.

@chenjt2001 chenjt2001 added the bug 🐛 An unexpected issue that highlights incorrect behavior label May 5, 2022
@ghost ghost added the needs triage 🔍 label May 5, 2022
@ghost
Copy link

ghost commented May 5, 2022

Hello chenjt2001, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@michael-hawker michael-hawker added this to the 8.0 milestone May 5, 2022
@michael-hawker michael-hawker added this to Triage in Bugs 8.0 via automation May 5, 2022
@michael-hawker
Copy link
Member

Thanks for filing an issue @chenjt2001!

We're registering to the SizeChanged event here, so I would have suspected this to be fired in this scenario to update the shadow:

elementNew.SizeChanged += shadow.CastToElement_SizeChanged;
// Re-trigger updates to all shadow locations for new parent
shadow.CastToElement_SizeChanged(null, null);
}
}
}
private void CastToElement_SizeChanged(object sender, SizeChangedEventArgs e)
{
// Don't use sender or 'e' here as related to container element not
// element for shadow, grab values off context. (Also may be null from internal call.)
foreach (var context in EnumerateElementContexts())
{
if (context.IsInitialized)
{
// TODO: Should we use ActualWidth/Height instead of RenderSize?
OnSizeChanged(context, context.Element.RenderSize, context.Element.RenderSize);
}
}
}

Maybe this is related to the note here about the existing rendersize vs. actualsize? Or possibly a delay between those values updating and the next layout pass occurring... Maybe we need to dispatch this or use the CompositionTargetHelper to ensure that the element has the correct size (though I would have thought it should have that by the SizeChanged is fired).

If this is enough for you to dig-in and debug, let me know if you want to take a look at it. If you need more assistance in getting the sample app to run locally to reproduce, let us know too. Thanks!

@chenjt2001
Copy link
Contributor Author

Thanks. I found that the RenderSize is correct and the problem is that the mask is not updated. See the PR #4549.

@LalithaNadimpalli
Copy link
Contributor

I copy pasted the Grid code in the sample app and see the issue when we adjust the window size changes abnormally and the PR created fixes the issue(Shadow remains constant as we adjust the window size)

@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Sep 2, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 hotfix 🌶
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants