ItemsControl button click command

后端 未结 4 2115
礼貌的吻别
礼貌的吻别 2021-02-07 21:32

I need some quick help which is a road blocker for me now. I have Button in ItemsControl and I need to perform some task on Button click. I tried addin

4条回答
  •  自闭症患者
    2021-02-07 22:32

    The DataContext of each item in your ItemsControl is the item in the collection the ItemsControl is bound to. If this item contains the Command, your code should work fine.

    However, this is not usually the case. Typically there is a ViewModel containing an ObservableCollection of items for the ItemsControl, and the Command to execute. If this is your case, you'll need to change the Source of your binding so it looks for the command in ItemsControl.DataContext, not ItemsControl.Item[X]

提交回复
热议问题