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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:01:26+00:00 2026-05-23T07:01:26+00:00

What is the use of ConvertBack method in the IValueConverter interface. When will it

  • 0

What is the use of ConvertBack method in the IValueConverter interface.

When will it be called?

Or what is the order of invocation of the Convert and ConvertBack methods?

I have asked the question here because: I have bound one property of codebehind to TEXTBOX’s TEXT Property and am using convertor for that property. The first Convert Method invokes and when I change TEXT in TEXTBOX nothing happens… but as soon as I close the form the ConvertBack method invokes.

  • 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-23T07:01:27+00:00Added an answer on May 23, 2026 at 7:01 am

    IMO, the ConvertBack method is used to convert your visual representation of the data to the specific DataType.

    For example: you use a Converter to convert a boolean true to the string "TrueBoolean". This text will be displayed in your TextBox. When you change the value of the TextBox, the ConvertBack method will be called as soon as the binding fires again (default OnFocusLost). Now your ConvertBack method will try to convert the new value to the datatype you want it to be. So you will have to implement logic to convert "FalseBoolean" to false.

    public class Converter : IValueConverter
    {
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool) value ? "TrueBoolean" : "FalseBoolean";
        }
    
        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var s = (string) value;
            if (s.Equals("TrueBoolean",StringComparison.CurrentCultureIgnoreCase))
                return true;
            if (s.Equals("FalseBoolean", StringComparison.CurrentCultureIgnoreCase))
                return false;
            throw new Exception(string.Format("Cannot convert, unknown value {0}", value));
        }
    }
    

    This technique is used a lot in DataGrids if I’m not mistaken.

    Hope this is a bit clear…

    UPDATE
    About you question in the comment:
    To overwrite the default OnFocusLost binding behavior you have to change your binding like this:

    <TextBox Text="{Binding MyText, UpdateSourceTrigger=PropertyChanged}"/>
    <!--syntax might differ, can't access VS at the moment.-->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not sure Why we need to use I ConvertBack method in IValueConverter
use javascript or other method ? have any recommendation?
Is there a way to access the ConvertBack-Method of a Converter that implements IValueConverter
Use Case When a user goes to my website, they will be confronted with
I have a label control where I use a converter to switch its styles
I currently use the following method to set the colour of my Row Background.
It's a very simple problem that I have. I use XDocument to generate an
I have the following converter defined (C#): class BodyValueConverter : IValueConverter { public object
I have a big mystery here, I have a Gdataxml document property: GDataXMLDocument *doc;
If i use an IValueConverter it works, while with an IMultiValueConverter returning the same

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.