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 3453194
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:20:46+00:00 2026-05-18T09:20:46+00:00

I have a bool property in my ViewModel called IsConnected and I would like

  • 0

I have a bool property in my ViewModel called IsConnected and I would like to bind it to a TextBlock in my MainWindow. Rather than have the textblock read true or false I need it to say Connected or Disconnected instead. Forgive me because I’m new to WPF. If someone could give me a head start I can take it from there but I’m not sure how to figure out what I need.

  • 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-18T09:20:47+00:00Added an answer on May 18, 2026 at 9:20 am

    I’d generally prefer to just add a property to the view model (I really dislike value converters), but here’s a simple way to accomplish what you’re trying to do using a style:

    <TextBlock>
      <TextBlock.Style>
        <Style TargetType="TextBlock">
          <Setter Property="Text" Value="Connected"/>
          <Style.Triggers>
            <DataTrigger Binding="{Binding IsConnected}" Value="False">
              <Setter Property="Text" Value="Disconnected"/>
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </TextBlock.Style>
    </TextBlock>
    

    Edit

    Note that once you get used to using data triggers, you can make all kinds of modifications to your view without touching your view model. For instance:

    <StackPanel>
       <Image Source="images\connected.png">
         <Image.Style>
            <Style TargetType="Image">
               <Setter Property="Visibility" Value="Collapsed"/>
               <Style.Triggers>
                  <DataTrigger Binding="{Binding IsConnected}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                  </DataTrigger>
               </Style.Triggers>
            </Style>
         </Image.Style>
      </Image>
       <Image Source="images\disconnected.png">
         <Image.Style>
            <Style TargetType="Image">
               <Setter Property="Visibility" Value="Collapsed"/>
               <Style.Triggers>
                  <DataTrigger Binding="{Binding IsConnected}" Value="False">
                    <Setter Property="Visibility" Value="Visible"/>
                  </DataTrigger>
               </Style.Triggers>
            </Style>
         </Image.Style>
      </Image>
    </StackPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an bool property in a class. And using <%= Html.EditorForModel() %> its
I have a form that has a public property public bool cancelSearch = false;
I have an interface for a creaky property-map: interface IPropertyMap { bool Exists(string key);
hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I would like to have a ComboBox control on a form which will be
I have an app that has a ListBox of ListBoxes. I would like to
I have a viewmodel called ArticleAdmin that includes a list of checkboxes: public class
I have a ViewModel with properties for a TextBox and a Checkbox: public bool
I have a ViewModel that looks like this: public class CreateReviewViewModel { public string
I have a checkbox in my xaml which is bind to a property and

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.