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

Binding to SelectedIndex does nothing?

2 Answers 464 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 23 Apr 2013, 09:48 PM
I can't seem make binding work on SelectedIndex ... I can make it work on SelectedItem, but if I bind to a property (integer) and change the property, nothing happens to the ComboBox (it's not being updated to reflect the new SelectedIndex).
<telerik:RadComboBox x:Name="CustomerAcctNameUsageComboBox" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource DCRadComboBoxFill}" ItemsSource="{Binding Path=LookupCustomerAcctNameUsage, Mode=TwoWay}" DisplayMemberPath="CustomerAccountNameUsageDesc" SelectedIndex="{Binding Path=Customer.CustomerAccountNameUsageID, Mode=TwoWay}"/>

2 Answers, 1 is accepted

Sort by
0
Rob Ainscough
Top achievements
Rank 1
answered on 23 Apr 2013, 10:04 PM
UPDATE: I got SelectedIndex working ... for some reason it does NOT like paths to objects properties

Binding Path=Customer.CustomerAccountNameUsageID

I setup a property for the parent object that has the main datacontext (in my case UICustomerInfo) and bound to that instead and SelectedIndex worked.  So apparently Path=Object.Property (Customer.CustomerAccountNameUsageID) is not a valid reference even though that reference is a valid property in my datacontext (UICustomerInfo).  Seems odd considering TextBox binding works find with Path=Object.Property so I'm not sure why SelectedIndex can't work this way also??

If someone can confirm or has more info, please fill me in.

Thanks, Rob.
0
Konstantina
Telerik team
answered on 26 Apr 2013, 01:42 PM
Hello Rob,

The ComboBox is a selector, so the SelectedIndex can pick up only properties or objects which are in its ItemsSource. Could you please give us some more details about the structure of your data and the DataContext of the ComboBox. If you can send us a sample project illustrating the issue it will be really helpful for resolving the issue in a timely manner.

Looking forward to your reply.

Regards,
Konstantina
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ComboBox
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Rob Ainscough
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or