我有一个ListBox绑定到一个ObservableCollection ItemTemplate包含另一个ListBox。首先,我想从我的MainWindowViewModel这种方式让所有的列表框的最后一个选择的项目(无论是家长和内部的):SelectionChanged的孩子列表框
public object SelectedItem
{
get { return this.selectedItem; }
set
{
this.selectedItem = value;
base.NotifyPropertyChanged("SelectedItem");
}
}
因此,例如,在项目的DataTemplate中父列表框我有这样的:
<ListBox ItemsSource="{Binding Tails}"
SelectedItem="{Binding Path=DataContext.SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
现在的问题是,当我选择从父ListBox中的项目,然后从孩子列表框中的项目,我得到这个:
http://i40.tinypic.com/j7bvig.jpg
如您所见,同时选择两个项目。我该如何解决这个问题?
在此先感谢。