У меня есть список, связанный со словарем, в котором хранятся мои ViewModels, в этом списке отображается ключ KeyValuePair в словаре.
<ListBox Style="{StaticResource MenuListBox}" x:Name="MenuItems" ItemsSource="{Binding Path=Screens}" ItemContainerStyle="{StaticResource MenuListBoxItem}" SelectedItem="{Binding Path=CurrentView}" />
CurrentView - это текущий вид, который отображается в ContentControl.
Когда выбор изменяется в ListBox, я получаю это исключение:
System.Windows.Data Error: 7 : ConvertBack cannot convert value '[Top 100, ModBox.ViewModel.Top100ViewModel]' (type 'KeyValuePair`2'). BindingExpression:Path=CurrentView; DataItem='MainViewModel' (HashCode=18169760); target element is 'ListBox' (Name='MenuItems'); target property is 'SelectedItem' (type 'Object') NotSupportedException:'System.NotSupportedException: TypeConverter cannot convert from System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[GalaSoft.MvvmLight.ViewModelBase, GalaSoft.MvvmLight.WPF4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=63eb5c012e0b3c1c]].
Он пытается преобразовать KVP в ViewModelBase, как я могу сделать так, чтобы он устанавливал ЗначениеКВП для CurrentView?