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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:37:10+00:00 2026-06-13T11:37:10+00:00

I have a WPF TextBox with the Text property bound to a data source.

  • 0

I have a WPF TextBox with the Text property bound to a data source. I am also binding the IsEnabled property of a second TextBox to the Text.Length property of the first in order to disable the second box when there is nothing entered in the first box. The problem is I want the text source to update on property changed but the IsEnabled to only update on lost focus but I can only define one UpdateSourceTrigger for the text properly.

One way around this would be to manually enable and disable the textboxes on the lost focus event of the previous text boxes. However since there are a lot of these text boxes each with its IsEnabled bound to the previous box’s Text property this would be messy. I was wondering if there was a cleaner way of doing this in the Xaml.

<TextBox Name="box1" Text="{Binding textSource1, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
<TextBox Name="box2" IsEnabled="{Binding ElementName=box1, Path=Text.Length}" Text="{Binding textSource2, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>

Here I want the IsEnabled property of box2 to update when box1 loses focus but textSource1 to update when the Text property on box1 changes.

  • 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-13T11:37:11+00:00Added an answer on June 13, 2026 at 11:37 am

    You could use a MultiBinding class.

    <TextBox Name="box2"  Text="{Binding textSource2, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Margin="321,64,113,217">
            <TextBox.IsEnabled>
                <MultiBinding  Converter="{StaticResource myConv}">
                    <Binding ElementName="box1" Path="Text.Length" />
                    <Binding ElementName="box1" Path="IsFocused" />
                </MultiBinding>
            </TextBox.IsEnabled>
    </TextBox> 
    

    Then you need a converter class with the desired custom logic

    public class MyConverter : IMultiValueConverter
    {
    
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int textLength = (int)values[0];
            bool isFocused = (bool)values[1];
    
            if (textLength > 0)
                return true;
    
            if (isFocused == true)
                return true;
    
            return false;
        }
    
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF TextBox , with the Text property bound to an int
I have a TextBox in a WPF window bound to a dependency property of
I have the following binding in my wpf application xaml: <TextBox Text={Binding Amount, StringFormat=c}
I have a TextBox bound to a ViewModel's Text property with the following setup:
I have a textbox in a WPF application bound to a property on a
I have a WPF view with a TextBox, binding the Text field to a
I have a TextBox in my WPF window. I have a property in the
I have a two way binding on a string dependency property to the Text
I have an WPF usercontrol that has a TextBox. I set the text Underline
I just noticed that WPF textboxes bound to numeric data do not fire Property

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.