将WPF Button CommandParameter绑定到DataTemplate中的Button本身
我有一个表示AppBar按钮的DataTemplate,我通过一组自定义AppBarCommand对象声明这些按钮。
public AppBarCommand(RelayCommand command, string buttonstyle) { Command = command; ButtonStyle = buttonstyle; }
我想添加一个CommandParameter绑定,但参数必须是Button本身。 这样我就可以设置Callisto弹出窗口的PlacementTarget。 这可能吗?
您的Command属性应该是RelayCommand
的通用版本: RelayCommand
。
像MiklósBalogh这样的答案说,或者你可以: