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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:55:25+00:00 2026-05-23T05:55:25+00:00

While bringing an application from .NET 3.5 to .NET 4.0 I’ve run into this

  • 0

While bringing an application from .NET 3.5 to .NET 4.0 I’ve run into this peculiar issue.

(culture is nl-BE)

I bind a TextBox like this (in XAML) to a DateTime value with an UpdateSourceTrigger on PropertyChanged (LostFocus works as expected but as-you-type validation is required):

<TextBox Height="23" Margin="146,0,105,97.04" Name="txb_Geboortedatum" VerticalAlignment="Bottom">
        <TextBox.Text>
            <Binding Path="Geboortedatum" StringFormat="d" 
                     UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <ExceptionValidationRule />
                </Binding.ValidationRules>
            </Binding>
        </TextBox.Text>
</TextBox>

Now when the contents of this textbox is (for example) 10/12/2000 and I want to edit it to be 09/03/1981 some obnoxious auto-correction occurs when i put the cursor at the end of 2000 and start ‘backspacing’ away the year value (when only the first digit (‘2’) of ‘2000’ is left the value automatically – including cursor jump – changes to 2002 again). Can I disable this auto-correction?

I can’t seem to find what specifically introduced this behaviour. The same ‘problem’ also occurs with FormatString=c for currency values.

What I’ve tried so far:

  1. Changing the FormatString to something more explicit like {0}{dd/MM/yyyy} (same problem: starts auto-correcting when there are 2 digits for year left).
  2. Disabling the following snippet I’ve added to my App.xaml.cs:

    FrameworkElement.LanguageProperty.OverrideMetadata(
        typeof(FrameworkElement), 
        new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(
            CultureInfo.CurrentCulture.IetfLanguageTag)));
    

The reasoning for this snippet to be included in the first place: have a look at this link.

Am i missing something obvious here? I can’t reproduce this in 3.5. Do I really have to roll my own ValueConverters for getting this to work properly? That looks like a step back from StringFormat which was introduced in 3.5 sp 1.

Output from DateTimeFormatInfo.CurrentInfo.GetAllDateTimePatterns('d') does looks slightly different, nothing that would immediately explain the behaviour though (probably unrelated):

.NET 3.5        .NET 4.0

d/MM/yyyy       d/MM/yyyy
d/MM/yy         d/MM/yy
dd-MM-yy        dd-MM-yy
dd.MM.yy        dd.MM.yy
yyyy-MM-dd      dd.MMM.yyyy
                yyyy-MM-dd

  • 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-23T05:55:25+00:00Added an answer on May 23, 2026 at 5:55 am

    I ended up using something like this for now, but I would be extremely interested in other approaches for solving the problem above:

    public class CustomDateTimeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, 
                              CultureInfo culture)
        {
            if (value == null) { return ""; }
            DateTime dt;
            if (DateTime.TryParse(value.ToString(), CultureInfo.CurrentCulture, 
                                  DateTimeStyles.None, out dt))
            {
                return dt.ToShortDateString();
            }
            return "";
        }
    
        public object ConvertBack(object value, Type targettype, object parameter, 
                                  CultureInfo culture)
        {
            if (value == null || value.ToString().Trim().Length==0) { return null; }
            string frmt = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
            DateTime dt;
            if (DateTime.TryParseExact(value.ToString(), frmt, 
                                       CultureInfo.CurrentCulture, 
                                       DateTimeStyles.None, out dt))
            {
                return dt;
            }
            return DependencyProperty.UnsetValue;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While cross-site scripting is generally regarded as negative, I've run into several situations where
While going through university and from following the development of SO, I've heard a
I was reading this article Build Your First Cloud Application Using Visual Studio 2010
I would like to build a web interface to present logdata. This should be
I searched internet and SO but could not get solution to this issue. I
Yo, Alright been noodling on this one for a while: How copy/cut styled text
I'd like to do something like this: twistedServer.start() # This would be a nonblocking
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
While I've seen rare cases where private inheritance was needed, I've never encountered a
While setting up CruiseControl, I added a buildpublisher block to the publisher tasks: <buildpublisher>

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.