WPF User Control hell with MVVM and Dependency Properties

前端 未结 4 524
醉酒成梦
醉酒成梦 2020-12-09 10:41

This is what I\'m trying to do:

  • I\'m writing a UserControl that I want to be consumed by other developers.
  • I want end users to be able

4条回答
  •  旧巷少年郎
    2020-12-09 11:19

    First off, I don't think MVVM is a good choice if you are developing a UserControl that will be consumed by others. A lookless control is what you really should be developing. Jeremiah Morrill has a blog post about this subject.

    With that said, you can set the datacontext with XAML if you have a default public constructor.

    Inside ControlView.xaml put:

    
        
    
    

提交回复
热议问题