Bound WPF TextBox is not updating value when the bound property enforces some business rules

前端 未结 1 592
小鲜肉
小鲜肉 2021-01-02 19:53

I am using .NET 4.0. I have some very simple code that lets the user type in a number between 1 and 99,999 (inclusive). I have some logic in the Property setter that preve

相关标签:
1条回答
  • 2021-01-02 20:33

    This seems to be a bug with the TextBox in .NET 3.5-4.0. I first tried this in 4.5 and your code worked as written, but when I converted the project to 4.0, I could reproduce the issue. After doing some searching, I found:

    WPF Textbox refuses to update itself while binded to a view model property, which details a workaround that references:

    Textbox getting out of sync with viewmodel property.

    Of course if it's possible for you to use .NET 4.5 I'd suggest that, but of course it's not always as easy as that.

    0 讨论(0)
提交回复
热议问题