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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:43:39+00:00 2026-06-05T22:43:39+00:00

I want to bind a string value to a text box but only if

  • 0

I want to bind a string value to a text box but only if a check box is checked. So, if the checkbox is checked I want the textbox to display Message 1, if not then display Message 2.

What is the best way to do this? Is it better to use a List property in my object and then depending on if the check box is checked or not depends on which item from within my List<> is displayed

or

is it better to just update the object’s property (this time of type string) after the checkbox is selected and then re-bind?

  • 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-05T22:43:40+00:00Added an answer on June 5, 2026 at 10:43 pm

    Here is one MVVM type of approach that assumes you understand INotifyPropertyChanged (you need to!). Play with it and feel free to ask about anything you get stuck on.

    VM (viewmodel code)

    public class MyViewModel : INotifyPropertyChanged {
    
        const string Msg1 = "blah 1";
        const string Msg2 = "blah 2";
    
        private bool _isSelected;
        public bool IsSelected{
            get { return _isSelected; }
            set {
                if(_isSelected == value) return;
    
                _isSelected = value;
                MyBoundMessage = _isSelected ? Msg1 : Msg2;
    
                NotifyPropertyChanged(()=> IsSelected);
                NotifyPropertyChanged(()=> MyBoundMessage);
            }
        }
    
        public string MyBoundMessage {get;set;}
    }
    

    V (view XAML)

    <CheckBox IsChecked="{Binding IsSelected}" />
    <TextBox Text="{Binding MyBoundMessage}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bind the user score to a text box on the windows
I want to bind string property with Button.Content. But why it didn't work? The
The ItemsSource (SsString) is a SortedSet string I want to use a TextBox (not
I want to bind a function to an event but I want to change
I want to bind to a value in a dictionary property of an object.
I want to implement that when a textbox value is changed, my Add button
I have a text box for user to enter 6 character hex color value,
My command object have a list of objects. I want to bind a text
i want to tightly bind my property using html helper for TextBoxFor but i
I want to bind Groupboxes to my stackpanel. c#: internal ObservableCollection<GroupBox> BindingTest { get

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.