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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:35:49+00:00 2026-06-07T22:35:49+00:00

I use XAML and data binding (MVVM). I need to update a Label when

  • 0

I use XAML and data binding (MVVM). I need to update a Label when my user write a new text character in a TextBox.

XAML

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="463" Text="{Binding OriginalText}"/>
        <Label Height="28" HorizontalAlignment="Left" Margin="12,41,0,0" Name="label1" VerticalAlignment="Top" Width="463" Content="{Binding ModifiedText}"/>
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="400,276,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    </Grid>
</Window>

ViewModel

    class MainViewModel : NotifyPropertyChangedBase
    {
        private string _originalText = string.Empty;
        public string OriginalText
        {
            get { return _originalText; }
            set
            {
                _originalText = value;
                NotifyPropertyChanged("OriginalText");
                NotifyPropertyChanged("ModifiedText");
            }
        }

        public string ModifiedText
        {
            get { return _originalText.ToUpper(); }
        }
    }

I added a button in the XAML. The button do nothing but help me to lose the focus of my textbox. When I lose the focus the binding is updated and the upper text appears in my label. But the data binding is only ever updated when the text loses focus. The TextChanged event doesn’t update the binding. I would like to force the update on the TextChanged event. How can I do that? What component should I use?

  • 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-07T22:35:51+00:00Added an answer on June 7, 2026 at 10:35 pm
     <TextBox Name="textBox1"
          Height="23" Width="463"
          HorizontalAlignment="Left" 
          Margin="12,12,0,0"   
          VerticalAlignment="Top"
          Text="{Binding OriginalText, UpdateSourceTrigger=PropertyChanged}" /> 
    

    MSDN How to: Control When the TextBox Text Updates the Source:

    The TextBox.Text property has a default UpdateSourceTrigger value of
    LostFocus. This means if an application has a TextBox with a
    data-bound TextBox.Text property, the text you type into the TextBox
    does not update the source until the TextBox loses focus (for
    instance, when you click away from the TextBox).

    If you want the source to get updated as you are typing, set the
    UpdateSourceTrigger of the binding to PropertyChanged. In the
    following example, the Text properties of both the TextBox and the
    TextBlock are bound to the same source property. The
    UpdateSourceTrigger property of the TextBox binding is set to
    PropertyChanged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To bind to the current DataContext in XAML you can use: <TextBlock Text={Binding} />
I've found that in order to use PRISM's classes in XAML you need to
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
I'm unable to use data binding in the ItemContainerStyle for a ListBox in Silverlight
I am struggling with the learning curve on WPF data binding and could use
I'm using XAML data binding for a ListBox whose ItemSource is set to a
I'm new to WPF data binding. I have a ListBox on a form that
I'm trying to learn how to use WPF binding and the MVVM architecture. I'm
I want to use data binding with an XML document to populate a simple
I am trying to use MVVM in my WPF application which displays data from

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.