这很简单:
将属性添加CurrentPerson到ViewModel并将其绑定到SelectedItemListBox 的属性.
像这样的东西:
查看型号:
public Person CurrentPerson
{
get { return _currentPerson; }
set
{
if(value == _currentPerson) return;
_currentPerson = value;
NotifyOfPropertyChange("CurrentPerson");
}
}
Run Code Online (Sandbox Code Playgroud)
视图:
<ListBox SelectedItem="{Binding CurrentPerson}" ...>
Run Code Online (Sandbox Code Playgroud)