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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:12:30+00:00 2026-05-26T17:12:30+00:00

I have a simple IValueConverter which just uses a TypeConverter to do the conversions.

  • 0

I have a simple IValueConverter which just uses a TypeConverter to do the conversions. However there are some cases where the TypeConverter provided will fail.

I would like to fall back to whatever WPF would have used if the the Binding was not provided with a converter. Using reflector I have determined that there is a DefaultValueConverter however it is internal to MS.Internal.Data.

Is there a simple way I can get my hands on a DefaultValueConverter or something that does the same thing?

  • 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-26T17:12:30+00:00Added an answer on May 26, 2026 at 5:12 pm

    I looked a bit around with .NET reflector and it seems there is not an official way to get the default value converter.

    What you need to be precise is to call the method

    internal IValueConverter GetDefaultValueConverter(Type sourceType, Type targetType, bool targetToSource);
    

    in class MS.Internal.Data.DataBindEngine.

    You would get the current DataBindEngine for running thread with the static internal property

     internal static DataBindEngine CurrentDataBindEngine
    

    Always in DataBindEngine class.

    The problem is that the class is internal!

    I looked also around to see if there is something public that uses that method but in reality that method and the default value converter classes (there is more than one!) are used only inside the internal databinding classes, so, no way out, sorry.

    You could use reflection to access the internal members, but it would be a very bad dirty hack!
    To do that, access to the static property DataBindEngine.CurrentDataBindEngine, then, access to the method GetDefaultValueConverter, always with reflection.
    Wrap in a static function with the attribute [Obsolete] 🙂

    Probably a cleaner way is to just use a default hand-written conversion.

    You can just try understand why it gives you error or write a code that can handle the special cases. Their code is quite complicated and interlinked, I would not suggest to copy their code.

    Sometime WPF makes me angry, a lot of things related to databinding are hidden, internal or not enough generic, and this is a really bad design choice that I don’t understand.

    The old TypeConverter sometime is enough. It depends on what you have to do.

    public static object MyConvert(object value, Type t)
    {
        TypeConverter tc = TypeDescriptor.GetConverter(t);
        return tc.ConvertFrom(value);
    }
    

    You can also try the static method Convert.ChangeType that works with IConvertible.

    I guess the problem is not in converting your object but converting it into a value used by a dependency property (or viceversa).
    For this purpose there is the public class XamlValueConverter, used also internally by default value converters.
    This is going to be complicated however, so … not a real simple solution to your problem.

    As Merlyn keep saying, I’m starting to believe that reflection may be a more suitable way.

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

Sidebar

Related Questions

I have a simple scenario and a issue with it which I just cant
I have simple list: <ul> <li>some text 1 </li> <li>some text 2</li> <li>some text
I have simple SSIS package which reads data from flat file and insert into
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple SSIS package in which On Error event handler I have created
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
I have simple rotation transformation, combined with alpha, which works perfectly on the first
I have a simple converter which checks if an object is equal to whatever
I have a simple ComboBox that has some simple values. I'm trying to do
Have simple C# console app which imports text data into SQL. It takes around

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.