【问题标题】:UWP DropShadow Stretch horizontallyUWP DropShadow 水平拉伸
【发布时间】:2020-03-21 16:59:16
【问题描述】:

我在 UWP 应用程序中有一个列表,我想在该列表中添加阴影。到目前为止有效,但是当我添加这些项目时,这些项目不再水平拉伸:

我已经定义了这种风格:

                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        <Setter Property="VerticalContentAlignment" Value="Stretch" />
                    </Style>
                </ListView.ItemContainerStyle>

【问题讨论】:

    标签: uwp uwp-xaml windows-community-toolkit


    【解决方案1】:

    DropShadow的默认样式开始,由于它将Horizo​​ntalContentAlignment属性设置为Left,因此您的listViewItem仍然无法水平拉伸。所以还需要将 DropShadow 的 Horizo​​ntalContentAlignment 设置为 Stretch。

    <ListView ItemsSource="{x:Bind Lists,Mode=OneWay}" Background="AliceBlue">
        <ListView.ItemTemplate>
            <DataTemplate>
                <controls:DropShadowPanel BlurRadius="4.0" ShadowOpacity="0.70"
                          OffsetX="5.0" OffsetY="5.0" Color="Black" HorizontalContentAlignment="Stretch">
                    ......
                </controls:DropShadowPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="VerticalContentAlignment" Value="Stretch" />
            </Style>
        </ListView.ItemContainerStyle>
    </ListView>
    

    【讨论】:

      猜你喜欢
      • 2020-01-25
      • 2016-10-27
      • 2019-12-26
      • 1970-01-01
      • 1970-01-01
      • 2011-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多