I use MVVM Light (WPF).
I want to build a menu of checkboxes styled as ToggleButtons in a ListView and show some controls in a contentcontrol depending on which checkbox is being checked. The ItemSource of the ListView I have set to an ObservableCollection<ViewModelInfo> where the ViewModelInfo objects holds information about the ViewModel and View to show. The listview's SelectedItem I have bound to a SelectedViewModelInfoItem property on the ViewModel. The SelectedViewModelInfoItem property will grab the information from the selected ViewModelInfo item and set the correct content control.
<ListView Grid.Column="0" Grid.Row="0" Grid.RowSpan="10"
ItemsSource="{Binding LeftPaneViewModelInfoItems}"
Background="Transparent" SelectedItem="{Binding SelectedViewModelInfoItem}">
<ListView.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding Text}"
Style="{StaticResource RadioButtonToggleButtonStyle}"
GroupName="DisplayPage"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
The problem I see is that the selection of the ListView seems completely separate from the RadioButtons checked state, so I have to click next to the toggle button to select it also I get an overlay color from the ListView.
Question: How do I easiest show my collection of ViewModeInfo as a list of togglebuttons making sure I only see a list of togglebuttons (not the highlight overlay from the ListView) still making sure the selected (checked togglebutton) is set as the SelectedViewModelInfoItem.
I should mention I have explored the EventToCommand, binding the Radiobutton's Checked event to a RelayCommand on the ViewModel. It would work if I could just get the actual ViewModelItem as an event argument instead of the default EventArgs (which source is the radiobutton). I was not able to solve it that way, but if there is a way to get the ViewModelItem as the eventarg it could be a nice solution.
UpdateSourceTrigger=PropertyChangedon the ItemsSource binding is pointless. It has no effect in a OneWay Binding like this. - Clemensboolproperty with his model to represent the Selection. I see that, he is relying on theListView'sSelectedItemto get the checked item. - dhilmathy