OneWayToSource Binding seems broken in .NET 4.0

前端 未结 6 656
我寻月下人不归
我寻月下人不归 2020-11-27 05:45

OneWayToSource Binding seems broken in .NET 4.0

I have this simple piece of Xaml


    

        
6条回答
  •  旧巷少年郎
    2020-11-27 05:58

    Is this the desired behavior for a OneWayToSource Binding in .NET 4.0?

    Yes. This is done for developer's ability to change provided value without clumsy converters.

    What was the problem with the way it worked in 3.5?

    No problem. The way it worked in 3.5 didn't allow to correct provided values.

    In what scenarios is this new behavior better?

    When you need to correct provided values. If you don't need it, then you should just write correct property's getter and setter.

    public string TextProperty
    {
        get;
        set;
    }
    

    However, as I can see, changing UpdateSourceTrigger to "PropertyChanged" preserves values from being reread (so you could leave old property declaration):

    
        
        

提交回复
热议问题