Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8443623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:11:18+00:00 2026-06-10T09:11:18+00:00

I have a textbox that a user puts a server name into, and it’s

  • 0

I have a textbox that a user puts a server name into, and it’s validated as an FQDN as he types. I also have a style that gets applied when the validation fails that makes the background of the textbox pink. However, I don’t want this to happen when high contrast mode is on and I can’t really seem to find much literature on how to accomplish this.

Here’s the textbox/style:

<TextBox ...>
    <TextBox.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ServerName.HasErrorsToShow}" Value="true">
                    <Setter Property="TextBox.Background" Value="Pink" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBox.Style>
</TextBox>

How can I accomplish this? Thanks!

EDIT 1:

I tried using a MultiTrigger. It seems promising, but I can’t quite get it right. This chunk of code worked (for testing whether I could base decisions on high contrast):

<Style.Triggers>
    <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="True">
        <Setter Property="TextBox.Background" Value="Pink" />
    </DataTrigger>
</Style.Triggers>

But when I tried adding the MultiTrigger, I got a “Set property ‘System.Windows.FrameworkElement.Style’ threw an exception” exception. The inner exception was “Must have non-null value for ‘Property'”. Here’s the code for that:

<Style.Triggers>
    <MultiTrigger>
        <MultiTrigger.Conditions>
            <Condition Binding="{Binding ServerName.HasErrorsToShow}" Value="True" />
            <Condition Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="False" />
        </MultiTrigger.Conditions>
        <Setter Property="TextBox.Background" Value="Pink" />
    </MultiTrigger>
</Style.Triggers>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:11:20+00:00Added an answer on June 10, 2026 at 9:11 am

    I haven’t tested this code out, but perhaps you could use a MultiTrigger and bind to the HighContrast property of the SystemParameters object. Something like this:

    [removed, see below]

    Note: I’m pretty sure the HighContrast property of the static SystemParameters class is not a dependency property, and won’t raise NotifyPropertyChanged, so if the user changes the setting while the application is already open, I don’t believe the trigger will fire.

    Edit:
    This style seems to do the job for me.

    <Style x:Key="MyTextBoxStyle" TargetType="{x:Type TextBox}">
      <Setter Property="Tag" Value="{DynamicResource {x:Static SystemParameters.HighContrastKey}}"/>
      <Setter Property="Background" Value="Green"/>
      <Style.Triggers>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding ServerName.HasErrorsToShow}" Value="true"/>
                <Condition  Binding="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" Value="True"/>
            </MultiDataTrigger.Conditions>
            <Setter Property="Background" Value="Red"/>
        </MultiDataTrigger>
      </Style.Triggers>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox that the user can input into. Right now the user
I have a textbox that a user can type some text into. The area
Hi I have a textbox that takes a username input. When the user submits
I have a TextBox in a Windows Form that allows a user to enter
I have a composite drop down calendar user control that consists of a textbox
I have a textbox that when you put focus into it, it drops down
I have a textbox that allows a user to specify a search string, including
What I have is a program that takes user's input from a textbox and
I have a textBox control that lets the user their email address/addresses. The use
I have a TextBox that user can enter search-term in it. Its bind to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.