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

后端 未结 7 1299
小鲜肉
小鲜肉 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 11:37

    In my experience, it is best to design an interface layout against at least a sample of the data it will present. To do otherwise is to be blind to cheap insights and expensive oversights.

提交回复
热议问题