Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTrigger styles do not override element styles #24750

Closed
mattleibow opened this issue Sep 13, 2024 · 1 comment
Closed

DataTrigger styles do not override element styles #24750

mattleibow opened this issue Sep 13, 2024 · 1 comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@mattleibow
Copy link
Member

mattleibow commented Sep 13, 2024

    <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

@dotnet-policy-service dotnet-policy-service bot added the s/triaged Issue has been reviewed label Sep 13, 2024
@mattleibow mattleibow added the area-xaml XAML, CSS, Triggers, Behaviors label Sep 13, 2024
@mattleibow mattleibow added this to the Backlog milestone Sep 13, 2024
@mattleibow mattleibow added the t/bug Something isn't working label Sep 13, 2024
@mattleibow
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors s/triaged Issue has been reviewed t/bug Something isn't working
1 participant