WPf 如何将combox的selectionchanged事件和command绑定?

2024-12-12 22:24:36
推荐回答(1个)
回答1:

View层:
xmlns:i=http://schemas.microsoft.com/expression/2010/interactivity








ViewModel层:
public ICommand SelectItemChangedCommand { get; set; }
构造函数中
SelectItemChangedCommand = new ActionCommand(this.NotifySelectedItemChanged);
事件:
public void NotifySelectedItemChanged()
{
MessageBox.Show("Sucess");
}