WPF ReadOnly Dependency Properties using MVVM

前端 未结 4 1878
心在旅途
心在旅途 2020-12-10 16:47

I\'ve recently overridden the DevXpress WPF grid to give myself a SelectedObject property that I can access from my loosely bound ViewModel.

I\'ve made a SelectedObj

4条回答
  •  不知归路
    2020-12-10 16:50

    I'm a little late to this question considering it was asked almost 2 years ago :)

    I made a solution to dynamically be able to push read-only dependency properties to the source called PushBinding which I blogged about here. In your case it would look like this

    
        
             
         
        
     
    

    PushBinding works by using two Dependency Properties, Listener and Mirror. Listener is bound OneWay to the TargetProperty and in the PropertyChangedCallback it updates the Mirror property which is bound OneWayToSource to whatever was specified in the Binding.

    Demo Project can be Downloaded Here.
    It contains source code and short sample usage, or visit my WPF blog if you're interested in the implementation details.

提交回复
热议问题