Two-way binding to SelectedItem? -or- Why isn't there a ValueMemberPath?

4 posts, 0 answers
  1. Rob
    Rob avatar
    11 posts
    Member since:
    Apr 2011

    Posted 07 Mar 2012 Link to this post

    I have the ItemsSource of a RadListPicker bound to a Key/Value list. I've bound the key/value list to the ItemsSource of the RadListPicker. I'm trying to two-way bind the SelectedItem to a property on the ViewModel.

    On the WinForms RadComboBox, there are both DisplayMember and ValueMember, which makes data binding easy (set DisplayMember = "value", ValueMember = "key", and bind to SelectedValue). On RadListPicker, there is DisplayMemberPath but no ValueMemberPath. When I try to bind to SelectedItem, I get an ArgumentException "SelectedItem is not contained within the ItemsSource." exception, because it's trying to bind to the key/value pair object, not the key value of the pair.

    I'm trying to think if there's a way to write a two-way converter to do what I want, but I think I'd need access to the ItemsSource of the list picker in order to iterate over its items and pick the appropriate one.
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 12 Mar 2012 Link to this post

    Hi Rob,

    Thank you for contacting us.

    I am not sure that I understand exactly what you are trying to achieve. If I am right, you want a two-way binding to the SelectedItem in RadListPicker and when you change the bound item, you want the selection in the ListPicker to reflect the change. I have attached a quick sample that demonstrates a way to do this with a converter. Please, take a look at it and confirm that this is what you want to do. If not, please explain in more details, or prepare a sample that recreates your scenario, so I can assist you further.

    Please note that you will need to open a new support ticket in order to attach your sample application.

    I am looking forward to your response.

    All the best,
    Todor
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Rob
    Rob avatar
    11 posts
    Member since:
    Apr 2011

    Posted 12 Mar 2012 Link to this post

    Submitted as 521841. Hopefully it makes more sense with the sample code.
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 13 Mar 2012 Link to this post

    Hello Rob,

    Please refer to the support ticket that you sent us regarding the same topic.

    Thank you for your time.

    Kind regards,
    Todor
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top