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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:07:25+00:00 2026-05-26T15:07:25+00:00

Just a short question : In wpf, how do I set and get updatesourcetrigger

  • 0

Just a short question :
In wpf, how do I set and get updatesourcetrigger of a textbox in codebehind ?
Thanks

Update :
I follow AngleWPF’s code :

        var bndExp = BindingOperations.GetBindingExpression(this, TextBox.TextProperty);

        var myBinding
          = bndExp.ParentBinding;

        var updateSourceTrigger = myBinding.UpdateSourceTrigger;

But I got the exception :

An unhandled exception of type
‘System.Reflection.TargetInvocationException’ occurred in
PresentationFramework.dll Additional information: Exception has been
thrown by the target of an invocation.

  • 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-26T15:07:25+00:00Added an answer on May 26, 2026 at 3:07 pm

    What do you mean by UpdateSourceTrigger of TextBox? You mean to say UpdateSourceTrigger of TextBox.TextProperty‘s Binding?

    E.g. if you have a TextBox named myTextBox having its Text property bound to some source then you can easily get it’s UpdateSourceTrigger and Binding object via GetBindingExpression() call.

       var bndExp
         = BindingOperations.GetBindingExpression(myTextBox, TextBox.Textproperty);
    
       var myBinding
         = bndExp.ParentBinding; 
    
       var updateSourceTrigger
         = myBinding.UpdateSourceTrigger;
    

    But it is tricky to set UpdateSourceTrigger for an already used binding. E.g. in the above case you wont be able to set the myBinding.UpdateSourceTrigger to something else. This is not allowed when a binding object is already in use.

    You may have to deep clone the binding object and set new UpdateSourceTrigger to it and assign it back to the TextBox. Cloning does not exist for Binding class. You may have to write your own cloning code for the same.

      var newBinding = Clone(myBinding); //// <--- You may have to code this function.
      newBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
      myTextBox.SetBinding(TextBox.TextProperty, newBinding);
    

    Alternately ou can also try to detatch the existing Binding and update it and assign it back…

      myTextBox.SetBinding(TextBox.TextProperty, null);
      myBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
      myTextBox.SetBinding(TextBox.TextProperty, myBinding);
    

    Let me know if any of these tips helps.

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

Sidebar

Related Questions

I feel rather foolish as this is just a short question. I was reading
Just wanted to get an idea for ways (web) developers get round the short
This post may seem overly long for just the short question at the end
I just have a short question about switching the color of sifr objects on
Just a very short question about DropBox - is there any way to find
Short question: Has anybody got any C# code to parse robots.txt and then evaluate
Just a short question, to clarify some doubts. Are setters not run when an
Just a short question out of curiosity. string str = string; Console.WriteLine(str.EndsWith(string.Empty)); //true Console.WriteLine(str.LastIndexOf(string.Empty)
Short Question Are there any compelling reasons to update Django 1.2.5 to 1.3? If
Short question: Does Apple frown, or completely disallow apps to code specifically for a

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.