UWP Databinding: How to set button command to parent DataContext inside DataTemplate

后端 未结 3 740
灰色年华
灰色年华 2021-01-12 09:14

Short explanation of need: I need to fire the command of a button inside a DataTemplate, using a method from the DataContext of the ViewModel.

Short explanation of p

3条回答
  •  孤独总比滥情好
    2021-01-12 10:01

    What MVVM toolkit are you using (if any)? In MVVM Light, you can get a hold of ViewModel from DataTemplate same way you set DataContext for your view:

    
        

提交回复
热议问题