This is a migrated thread and some comments may be shown as answers.

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

3 Answers 172 Views
ListPicker
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob
Top achievements
Rank 1
Rob asked on 07 Mar 2012, 08:46 PM
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.

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Mar 2012, 02:47 PM
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 >>
0
Rob
Top achievements
Rank 1
answered on 12 Mar 2012, 05:04 PM
Submitted as 521841. Hopefully it makes more sense with the sample code.
0
Todor
Telerik team
answered on 13 Mar 2012, 03:42 PM
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 >>
Tags
ListPicker
Asked by
Rob
Top achievements
Rank 1
Answers by
Todor
Telerik team
Rob
Top achievements
Rank 1
Share this question
or