What is the advantage of setting DataContext in code instead of XAML?

后端 未结 7 1274
小鲜肉
小鲜肉 2020-12-09 10:54

There seem to be two main ways to define DataContext in WPF:

  • either in code like this:

App.xaml.cs (taken from the WPF MVVM Too

相关标签:
7条回答
  • 2020-12-09 12:01

    It should also be possible to use ObjectDataProvider to establish an object factory using Unity or other IOCs as implied here...

    http://social.msdn.microsoft.com/Forums/en/wpf/thread/1ff9e90e-302e-436e-bab3-ca4bad2b85af

    in particular...

    http://www.codeproject.com/Articles/43806/WPF-Ninject-Dojo-The-Data-Provider.aspx

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