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

Problem binding ComboBoxColumn

7 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 08 Dec 2010, 02:55 PM
I'm having some trouble with the ComboBoxColumn. Here is my code:

<telerik:GridViewComboBoxColumn 
   DataMemberBinding="{Binding ActionID}" 
   Header="Action" UniqueName="ActionID" 
   SelectedValueMemberPath="ActionID"
   DisplayMemberPath="Name"
   ItemsSourceBinding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=telerik:RadPane},Path=viewModel.References.ActionList}"/>

The rest of the columns are binding as expected. I was originally using ItemsSource and saw a thread that said to use ItemsSourceBinding instead. But neither one is working.

FYI: I'm also having trouble databinding several other gridviews using the same RelativeSource binding (but to different properties). I know my properties have items in them. I can see it when I debug, but the binding just isn't working for some of my controls. Other controls that are also bound using RelativeSource are working.

Is there something wrong with my comboBoxColumn or is there a limit on how many RelativeSource bindings I can use?

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 08 Dec 2010, 03:07 PM
Hi Rayne,

Firstly, you may take a look at our online documentation and demos on the topic of GridViewComboBoxColumn. Considering the bindings, the property set as the DataMemberBinding needs to be a part of the source of the grid, while those set for the DisplayMemberPath and SelectedValueMemberPath  need to be from the source of the GridViewComboBoxColumn. 
Considering the ItemsSource and the ItemsSourceBinding, the second one is used when the property keeping the data source for this column is defined in the business object. In case it is not, you can use the ItemsSource. 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Rayne
Top achievements
Rank 1
answered on 08 Dec 2010, 03:22 PM
I was using it in another project where the ItemsSource was a StaticReference and it worked fine. But I can't seem to get it to bind to a property on my ViewModel (which is what I need on this project).

I tried changing it to {Binding ElementName=ContentGrid, Path=DataContext.ActionList} and I'm having the same problem. This particular grid is part of a HeirarchyChildTemplate DataTemplate. Could that have something to do with why it's not finding the data it needs to bind to?
0
Maya
Telerik team
answered on 09 Dec 2010, 05:04 PM
Hello Rayne,

I am sending you a sample project illustrating how to bind a GridViewComboBoxColumn in the HierarchyChildTemplate to a property in the ViewModel.
Let me know if it resolves your issue.
 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Rayne
Top achievements
Rank 1
answered on 09 Dec 2010, 09:01 PM
My viewModel is not a static resource of the View because it has constructor parameters that are injected at runtime by Prism's Unity Bootstrapper.
0
Maya
Telerik team
answered on 11 Dec 2010, 04:53 PM
Hello Rayne,

I am sending you a sample project demonstrating the settings of a GridViewComboBoxColumn when using RelativeSource. I hope it helps.
 

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Rayne
Top achievements
Rank 1
answered on 13 Dec 2010, 05:33 PM
As you can see in my original post, for some reason the RelativeSource just wasn't working. It worked for a few other controls that were higher up the xaml tree, but not this ComboBox Column. I wasn't sure if it was because the ComboBox Column was in a hierarchy template. Thank you for clarifying that that shouldn't affect it.

I solved it by moving that particular property to a separate class that can be referenced as a StaticResource, but I wish I knew why my RelativeSource binding didn't work. I made sure all my paths were accurate.
0
Maya
Telerik team
answered on 13 Dec 2010, 06:12 PM
Hi Rayne,

I am glad to here that you solved the things out. Still let me know, if you need any further assistance on the topic.

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Rayne
Top achievements
Rank 1
Answers by
Maya
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or