0
votes

I have a list in a UWP Application where I would like to add shadows to the list. That works so far, but when I add those the items are no longer stretch horizontally:

enter image description here enter image description here

I already have defined this style:

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

1 Answers

1
votes

From the default style of DropShadow, since it sets the HorizontalContentAlignment property as Left, your listViewItem still can't stretch horizontally. So you also need to set the HorizontalContentAlignment of DropShadow as 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>