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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:44:12+00:00 2026-05-31T06:44:12+00:00

I have the following binding in my wpf application xaml: <TextBox Text={Binding Amount, StringFormat=c}

  • 0

I have the following binding in my wpf application

xaml:

   <TextBox Text="{Binding Amount, StringFormat=c}" Name="txtAmount"  />

c# (code behind):

public partial class MainWindow : Window, INotifyPropertyChanged
{
    public MainWindow()
    {
        InitializeComponent();

        // needed to create the binding  
        this.DataContext = this;
    }

    private decimal _Amount;

    public decimal Amount
    {
        get {
            return _Amount;
        }
        set{
            _Amount= value;
            OnPropertyChanged("Amount");             
        }
    }


    public event PropertyChangedEventHandler PropertyChanged = delegate { };

    private void OnPropertyChanged(string propertyName)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }

   //.....

that code works fine. The property Amount in my code behind will be updated whenever I change the value of txtAmount and also the other way around (changing the value of Amount in C# will update txtAmount)

Anyways how can I update amount every time I change the text in the control txtAmount? I don’t want to wait until txtAmount loses focus so that Amount get’s updated in the code behind.


Things I have tried:

        txtAmount.TextChanged += (a, b) =>
        {
            Amount = decimal.Parse(txtAmount.Text);
        };

Recall that my txtAmount is formatted as currency therefore if it has the value of 1 the txtAmount will display $1.00 I know that I should be able to replace the $ for nothing in order to be able to cast it to decimal. If this application where to use a different culture say for instance es for Spanish then the textbox will display a eruo instead of the $ and I will have to replace that symbol in order to be able to cast it.

So in short is there a way of being able to update the Amount property that is binded to my txtAmount control everytime the text changes in that control instead of when the control looses focus?

  • 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-31T06:44:14+00:00Added an answer on May 31, 2026 at 6:44 am

    Set the binding property UpdateSourceTrigger to PropertyChanged

    <TextBox Text="{Binding Amount, StringFormat=c, UpdateSourceTrigger=PropertyChanged}" Name="txtAmount"  />
    
    • 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 the following Xaml in a Window ( ArtistInfo ): <Grid> <TextBlock Text={Binding
I have the following DataTemplate : <DataTemplate x:Key=ColoringLabels> <TextBlock Padding=0 Margin=0 Name=Username Text={Binding Username}
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I have the following XAML in a WPF application. I would like to bind
Let's say I have the following code in WPF application: try { // NorthwindDataContext
I have the following code currently: <DataTemplate DataType={x:Type vm:SectionViewModel}> <ScrollViewer> <ItemsControl ItemsSource={Binding ViewModels}> </ItemsControl>
I have tried for unload and beforeunload binding in following code, but none of
I have a combo box with the following DataTemplate: <DataTemplate x:Key=ComboBoxDataTemplate> <StackPanel> <TextBlock Text={Binding
I have an ItemsControl with the following ItemTemplate: <DataTemplate x:Key=myItemTemplate> <TextBlock Height=??? Text={Binding Path=Description}

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.