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

  • SEARCH
  • Home
  • 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 7074827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:06:17+00:00 2026-05-28T06:06:17+00:00

I have: <TextBlock Text={Binding OrderType}/> OrderType is a string can potentially be A,B,C,D. But

  • 0

I have:

<TextBlock Text="{Binding OrderType}"/>

OrderType is a string can potentially be A,B,C,D. But I want the textblock to display YES if (A or B) and NO if (C or D), but want the foreground color to be Green if A, Blue if B, Yellow if C, Red if D. What would be the best way to do this? I’m a little confused if I use a converter, what the style trigger should bind to or if there is a better approach. Thanks.

  • 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-05-28T06:06:17+00:00Added an answer on May 28, 2026 at 6:06 am

    You can do this with Triggers only, there’s a bit of redundancy though:

    <TextBlock>
        <TextBlock.Style>
            <Style TargetType="TextBlock">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding OrderType}" Value="A">
                        <Setter Property="Text" Value="YES" />
                        <Setter Property="Foreground" Value="Green" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding OrderType}" Value="B">
                        <Setter Property="Text" Value="YES" />
                        <Setter Property="Foreground" Value="Blue" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding OrderType}" Value="C">
                        <Setter Property="Text" Value="NO" />
                        <Setter Property="Foreground" Value="Yellow" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding OrderType}" Value="D">
                        <Setter Property="Text" Value="NO" />
                        <Setter Property="Foreground" Value="Red" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBlock.Style>
    </TextBlock>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XAML: <TextBlock Text={Binding ElementName=EditListBox, Path=SelectedItems.Count} Margin=0,0,5,0/> <TextBlock Text=items selected> <TextBlock.Style>
I have a binding for ListBox but how I can add an event to
I have <TextBlock Text={Binding TexT} Style={StaticResource PhoneTextNormalStyle}/> Also have {Binding Read_State} (bool Read_State) How
I have a TextBlock that I want to display a user name, and email
I have problem with text wrapping. Without StackPanel this TextBlock works, but i need
Given that we have the following View: <StackPanel> <TextBlock Text=Some text/> <Image Source={Binding vmImageProp}
I have a TextBlock bound to a string. I want the string to be
In WPF, is there any way to have the Text property of a TextBlock
I have a TextBlock in resource data template: <DataTemplate x:Key=MyDataTemplate ItemsSource={Binding MySource}> <TextBlock x:Name=MyText
I have the next code in my view: <Style x:Key=documentFileNameStyle> <Setter Property=TextBlock.Foreground Value=Gray/> <Style.Triggers>

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.