I currently use a listview nested inside a listview as a way to show a Knockout style tournament graphically, backed up in ViewModel by SectionTreeOne, which contains a List of Lists of objects "TournamentNode". I cannot however get my selected "Tournament Node" to bind when I click on it.
<Grid Grid.Row="2">
<ListView ItemsSource="{Binding SectionTreeOne}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate >
<DataTemplate>
<ListView ItemsSource="{Binding}" SelectionMode="Single"
SelectedItem="{Binding SelectedTournamentNode}">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
C# binding:
Collection
public List<List<TournamentNodeModel>> SectionTreeOne
{
get { return _sectionTreeOne; }
set
{
_sectionTreeOne = value;
base.OnPropertyChanged("SectionTreeOne");
}
}
Selected Item:
public TournamentNodeModel SelectedTournamentNode
{
get { return _selectedTournamentNode; }
set
{
if (value == _selectedTournamentNode)
return;
_selectedTournamentNode = value;
base.OnPropertyChanged("SelectedTournamentNode");
}
}