What is the best approach to assign Data Context using MVVM?

后端 未结 2 878
借酒劲吻你
借酒劲吻你 2021-02-02 16:04

I was looking for best approach to set data context property. I found three ways

  1. Assign data context on View (either on XAML or code behind).

  2. As

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 16:56

    the 4. way would be a DataTemplate.

    i think the best approach is the one which fits best in your current situation.

    if i have viewmodel first dynamic scenarios i use datatemplate/contentpresenter or with view first i take your way one and so on...

提交回复
热议问题