dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

DataTrigger styles do not override element styles #24750

Closed mattleibow closed 1 month ago

mattleibow commented 1 month ago

    <CollectionView ItemsSource="{Binding Items}">
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <ContentView>
                    <ContentView.Triggers>
                        <DataTrigger TargetType="ContentView" Binding="{Binding .}" Value="Second">
                            <Setter Property="Background" Value="Purple"/>
                        </DataTrigger>
                    </ContentView.Triggers>
                    <Label Text="{Binding .}" FontSize="24" Background="Azure" />
                </ContentView>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

The color of the items should be Azure and the selected Purple, but they are all Azure.

If I remove the Background on the element, then all are white with one being Purple as I expected.

Archive.zip

mattleibow commented 1 month ago

The label background will cover the content view background... Oops.