UWPCommunityToolkit DropShadowPanel使Grid不会拉伸

Cal*_*ell 2 xaml uwp uwp-xaml windows-community-toolkit

我希望网格在屏幕上伸展同时还应用了阴影效果,出于某种原因,当放置在DropShadowPanel内部时,我无法将网格拉伸.

以下是所需结果的示例,但没有阴影效果:

<Grid Background="LightBlue">
    <Grid Background="WhiteSmoke" HorizontalAlignment="Stretch" Height="200" VerticalAlignment="Top" Margin="40"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

结果:

在此输入图像描述

这是我的带有DropShadowPanel的xaml:

<Grid Background="LightBlue">
    <controls:DropShadowPanel HorizontalAlignment="Stretch" Margin="40">
        <Grid Background="WhiteSmoke" HorizontalAlignment="Stretch" Height="200" VerticalAlignment="Top"/>
    </controls:DropShadowPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)

而这完全隐藏了第二个网格.

为什么网格在DropShadowPanel中的行为不同?

Nic*_*SFT 7

而这完全隐藏了第二个网格.

问题是你没有设置HorizontalContentAlignment属性DropShadowPanel.我修改了你的代码,如下所示.它有效.

<controls:DropShadowPanel Margin="40"
                          VerticalAlignment="Center"   
                          HorizontalAlignment="Stretch"
                          HorizontalContentAlignment="Stretch"
                          >
    <Grid Background="Red" Height="200" HorizontalAlignment="Stretch"/>
</controls:DropShadowPanel>
Run Code Online (Sandbox Code Playgroud)