WPF Styles and triggers

Whenever no selection is made from all checkboxes I want the user to see an orange border around the checkboxes. This is not a validation error, but a warning this is not the intended use. My style in XAML looks like this

<Style x:Key="WarningNoSelection" TargetType="{x:Type Border}">
            <Condition Binding="{Binding Path=AdminRole}"     Value="False" />
            <Condition Binding="{Binding Path=DataRole}"      Value="False" />
            <Condition Binding="{Binding Path=WebServer}"     Value="False" />
            <Condition Binding="{Binding Path=ResourceRole}"  Value="False" />
            <Condition Binding="{Binding Path=DataEntryRole}" Value="False" />
            <Setter Property="BorderBrush" Value="Orange"/>

With the debugger described here. I found that the trigger was working but stil no orange border around my checkboxes. The problem was the BorderBrush property specified in the Border Tag. After removing that I got my orange border when no checkbox was checked.

<Border BorderBrush="Silver" Style="{StaticResource WarningNoSelection}" BorderThickness="1">
<Border Style="{StaticResource WarningNoSelection}" BorderThickness="1">
        <CheckBox Content="Admin"     IsChecked="{Binding Path=AdminRole}" />
        <CheckBox Content="Data"      IsChecked="{Binding Path=DataRole}" />
        <CheckBox Content="WebServer" IsChecked="{Binding Path=WebServer}" />
        <CheckBox Content="Resource"  IsChecked="{Binding Path=ResourceRole}" />
        <CheckBox Content="DataEntry" IsChecked="{Binding Path=DataEntryRole}" />

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.