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

Binding to datacontext object

2 Answers 173 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jon Bergquist
Top achievements
Rank 1
Jon Bergquist asked on 17 Dec 2008, 02:49 AM
Hi - I have a combobox that is bound to a Dictionary like so:

<telerik:RadComboBox x:Name="cboAgent" Grid.Row="4" Grid.Column="1" SelectedValuePath="Key" DisplayMemberPath="Value" Style="{StaticResource ComboBoxStyle}" SelectedValue="{Binding AgentId}" />

That part works fine.  What I'm trying to accomplish is setting the value of a datacontext object (business object set for the page) property whenever the selected item changes.  The AgentId property in the datacontext should update to whatever the SelectedValuePath value is whenever the combobox item changes.  I could do this in the SelectionChanged event but I know it can be done no code.

Thank you

Jon


2 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 17 Dec 2008, 09:48 AM
Hello Jon,

The no-code variant is using INotifyPropertyChanged implementation on your data class and using TwoWay bindings in XAML. Please, see my answer of your other forum post for code example.

Greetings,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jon Bergquist
Top achievements
Rank 1
answered on 17 Dec 2008, 03:57 PM
My bad.  I forgot the Mode=TwoWay setting.  It works now. 

Thanks
Tags
ComboBox
Asked by
Jon Bergquist
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Jon Bergquist
Top achievements
Rank 1
Share this question
or