Seaky Lone
Seaky Lone

Reputation: 1059

UWP listview mutiple ItemContainerStyle

How can I have my ListView have multiple ItemContainerStyle?

<ListView x:Name="SongsListView">
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        </Style>
        <!--<Style TargetType="ListViewItemPresenter">
            <Setter Property="SelectedPointerOverBackground" Value="White" />
        </Style>-->
    </ListView.ItemContainerStyle>
</ListView>

Upvotes: 0

Views: 687

Answers (1)

dotNET
dotNET

Reputation: 35460

The way you're trying to add multiple styles doesn't make any sense. You can't have more than one Style applied on a control at the same time. There is no point in doing that. However you can ask UWP to apply one of the many Styles programmatically.

UWP, just like WPF, supports ItemContainerStyleSelector. This is a simple class that allows you to select a Style based on some condition or procedure. You may check one working example here.

Upvotes: 0

Related Questions