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 IsItemClickEnabled="True" SelectedItem="{Binding SelectedRound, Mode=TwoWay}" SelectionMode="Single" ItemsSource="{Binding
SectionTreeOne, Mode=TwoWay}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate >
<DataTemplate>
<ListView SelectedItem="{Binding SelectedTournamentNode, Mode=TwoWay}" IsItemClickEnabled="True"
ItemsSource="{Binding TournamentNodes, Mode=TwoWay}" SelectionMode="Single" >
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
Selected Item (outer list view): **Note - this has no purpose and was placed in simply for testing selected items in the listview, this one works ***
private Round _selectedRound = new Round();
public Round SelectedRound
{
get { return _selectedRound; }
set
{
if (value == _selectedRound)
return;
_selectedRound = value;
OnPropertyChanged("SelectedRound");
IsAppBarOpen = true;
}
}
Selected Item (inner listview):**Note - this doesnt work and is the one i need working***
public TournamentNodeModel SelectedTournamentNode
{
get { return _selectedTournamentNode; }
set
{
if (value == _selectedTournamentNode)
return;
_selectedTournamentNode = value;
base.OnPropertyChanged("SelectedTournamentNode");
}
}
Collection:
private ObservableCollection<Round> _sectionTreeOne = new ObservableCollection<Round>()
public ObservableCollection<Round> SectionTreeOne{
get { return _sectionTreeOne; }
set
{
_sectionTreeOne = value;
base.OnPropertyChanged("SectionTreeOne");
}
}