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

Binding in GridViewComboBoxColumn

4 Answers 30 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 23 Mar 2011, 04:46 PM

Hi,
I have decided to use a GridViewComboBoxColumn instead of a ComboBox. But there is no SelectedValue property. When I change the dropdown value in the GridViewComboBox nothing happens in my VM. What is the correct way of mapping the properties in GridViewComboBox or what is the corresponding property to SelectedValue? This is what I've done so far:

                <t:GridViewComboBoxColumn Width="150" x:Name="Ebene1"
                                          ItemsSource="{Binding DataContext.EigenschaftenEbene1, ElementName=LimitControl, Mode=TwoWay}"
                                          DataMemberBinding="{Binding limk_gruppierung_ebene1, Mode=TwoWay}"
                                          SelectedValueMemberPath="Id"
                                          DisplayMemberPath="Bezeichnung">
                </t:GridViewComboBoxColumn>

Best regards,

Andreas


4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 23 Mar 2011, 04:55 PM
Hello Andreas,

Generally, the property from the source of the grid - the one defined in the DataMemberBinding will be changed. May you provide a bit more details about the exact scenario you want to achieve and the reason for binding the SelectedValue in your ViewModel ?
 

Best wishes,
Maya
the Telerik team
0
Andreas
Top achievements
Rank 1
answered on 23 Mar 2011, 05:15 PM
Hi Maya,

I have four ComboBoxes with four identical item lists. When I select one item in the first list, this item must be removed from the other three. So every time I change a selection I have to make sure the lists of the other ComboBoxes are updated. This worked fine with simple ComboBoxes but now I have had to move it in a GridView using the GridViewComboBoxColumn.
I have in my VM a property which I bound to the SelectedValue of the ComboBox but now I'm not sure how I can implement the same scenario in a GridView.

Regards,

Andreas
0
Accepted
Maya
Telerik team
answered on 24 Mar 2011, 05:26 PM
Hello Andreas,

Generally, this might be achieved by using ItemsSourceBinding of the GridViewComboBoxColumn. The ItemsSouceBinding should be bound to a property in your business object and you may work directly with it. However, if you work directly with the ItemsSource, you may result in removing items that may be necessary for another item in the grid.
May you share a bit more details about the exact implementation of your business object and the ViewModel you use ? 
 

Greetings,
Maya
the Telerik team
0
Andreas
Top achievements
Rank 1
answered on 25 Mar 2011, 08:27 AM
Hello Maya,

you are perfectly right I have to keep the ComboBoxes out of the grid.

Many thanks,

Andreas
Tags
GridView
Asked by
Andreas
Top achievements
Rank 1
Answers by
Maya
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or