Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6980319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:00:03+00:00 2026-05-27T18:00:03+00:00

I have a listbox bound to an Dictionary that holds my ViewModels, the listbox

  • 0

I have a listbox bound to an Dictionary that holds my ViewModels, the listbox displays the Key of the KeyValuePair in the Dictionary.

<ListBox Style="{StaticResource MenuListBox}" x:Name="MenuItems" ItemsSource="{Binding Path=Screens}" ItemContainerStyle="{StaticResource MenuListBoxItem}" SelectedItem="{Binding Path=CurrentView}" />

CurrentView is the current View that is getting displayed in a ContentControl.

When the selection changes in the ListBox I get this exception:

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]].

It is trying to convert a KVP to a ViewModelBase, how can I make it so it sets the Value of the KVP to the CurrentView?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:00:04+00:00Added an answer on May 27, 2026 at 6:00 pm

    In your case instead of the SelectedItem you need to bind to SelectedValue and use the SelectedValuePath property:

    <ListBox Style="{StaticResource MenuListBox}" x:Name="MenuItems" 
        ItemsSource="{Binding Path=Screens}" 
        ItemContainerStyle="{StaticResource MenuListBoxItem}" 
        SelectedValue="{Binding Path=CurrentView}"
        SelectedValuePath="Value" 
        />
    

    Because you don’t want to whole list box item selected just the Value property of the KeyValuePair.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox that displays a number of usercontrols that are bound to
I have a ListBox that is bound to a list of Persons. I want
I currently have a listbox that has its selected item bound to a property
I have a ListBox that is bound to a list of CustomerViewModel-objects, that each
Say I have a ListBox that is bound to an observable collection on my
I have a ListBox in a popup. It’s bound to a simple Dictionary. I
I currently have a view that contains a ListBox bound to a a collection
I have a ListBox bound to an ObservableCollection: <ListBox Name=ListBoxItemsList> <ListBox.ItemTemplate> <DataTemplate> <Grid Margin=0
I have a listbox that is bound to a List<T> -- this is working
I have a ListBox that is bound to a List. Every-time the ListBox updates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.