We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to bind a GridComboBoxColumn to a property of the element in the SfDataGrid collection?

Thread ID:





131548 Jul 16,2017 02:51 PM UTC Sep 5,2017 03:52 PM UTC WPF 12
Tags: SfDataGrid
Jay Timmins
Asked On July 16, 2017 02:51 PM UTC

It seems from the documentation and from my attempts that the GridComboBoxColumn and GridMultiColumnDropDownList have a DataContext of the root element, and not the SfDataGrid itself. How can you bind the column ItemsSource to a collection property owned by the object behind the record (an element of the grid collection)?
(Window DataContext is the ViewModel)
ItemsSource="{Binding VMColl}"> (A collection property exposed in the viewmodel)
ItemsSource="{Binding VMCollProp}"/> (This gives a databinding error saying it can't find this property on the ViewModel itself)

I've tried binding the SelectedItem of the sfDataGrid to a property in the view model, then declaring two properties which get the collection members from the selected item, and binding the ItemsSource to those. This is quite hacky and messy and doesn't work with GridMultiColumnDropDownList though.

Jay Timmins
Replied On July 16, 2017 06:48 PM UTC

Looks like the formatting lost some of my code example. It is meant to read:

Thank you.

Srinivasan Vasu [Syncfusion]
Replied On July 17, 2017 09:00 AM UTC

Hi Jay, 
Thanks for contacting Syncfusion support. 
We have checked your query and we have prepared a sample as per your requirement. The mentioned issue reproduced only when the bounded property not available in ViewModel and we did not reproduce the reported issue in our side. In sample, ComboItems property bound with GridComboBoxColumn which is declared in ViewModel. You can bound the collection property with GridMultiColumnDropDownList  column in the same way. 
Please refer the below code example. 
        <local:ViewModel x:Key="ordercollection"/> 
<syncfusion:GridComboBoxColumn HeaderText="Country" 
                                               ItemsSource="{Binding ComboItems,Source={StaticResource ordercollection}}" 
Please download the sample from the below link. 
If the issue still persists, please revert us the modified sample with the replication procedure. 
If your requirement is different from this, please provide more details and modified sample. It will be helpful to provide better support.  

Jay Timmins
Replied On July 18, 2017 05:44 PM UTC

Dear Srinivasan,Thanks for your response. Unfortunately in your sample this shows binding to a collection which is on the ViewModel. My collection is a property of the model. In all of the columns in your example, you are binding to a property of the Model itself, e.g. OrderID, CustomerName. I attached the sample - I made adjustments to the ViewModel and Model files with comments to show what I mean. Consider a collection property exposed on the model - is there a way to represent this as a GridComboBoxColumn, or a GridMultiColumnDropDownList so that it can be edited?Attachment: Annotated_Example_9a459312.zip

Srinivasan Vasu [Syncfusion]
Replied On July 19, 2017 04:31 AM UTC

Hi Jay, 
We cannot download the sample from the attachment. Please provide proper attached file. 

Jay Timmins
Replied On July 19, 2017 07:03 AM UTC

Looks like it got lost in the wires...


Attachment: Annotated_Example_ccac2403.zip

Jay Timmins
Replied On July 21, 2017 09:14 AM UTC

Any luck with this, or is it not possible to do this with the DataGrid?


Jay Timmins
Replied On July 21, 2017 09:47 PM UTC

Nevermind, I addressed this issue by using a GridTemplateColumn which actually binds to the properties on the model itself.

If anyone is in a similar situation and wanted to see my solution, feel free to drop me a message

Sivakumar R [Syncfusion]
Replied On July 22, 2017 01:50 PM UTC

Hi Jay, 

Sorry for the delay. We worked in creating custom column to meet your requirement for better performance over TemplateColumn. 

You can use Template column to achieve your requirement like you are doing already. 

I would suggest to use the custom column created in the below sample for better performance over TemplateColumn. 

<local:GridComboBoxColumnExt MappingName="OrderValue"> 
public class ItemsSourceSelectorSelector : IItemsSourceSelector 
    public IEnumerable GetItemsSource(object record, object dataContext) 
        if (record == null) 
            return null; 
        var model = record as Model; 
        return model.OrderValues; 

Below sample returns different ItemsSource for each row from data object associated with row. 

Below sample filters and returns different ItemsSource for each row from ViewModel. 


Jay Timmins
Replied On July 24, 2017 09:46 AM UTC

Dear Sivakumar,

Thanks for the great support! I'll play with your solution as I'm sure it's more performant.

Srinivasan Vasu [Syncfusion]
Replied On July 25, 2017 04:02 AM UTC

Hi Jay, 
Thanks for your update. 
Please let us know if you need further assistance. 

Marcin Sasin
Replied On August 31, 2017 01:51 PM UTC


It is extremely "un-intuitive" that You can't simply bind row element to underlying row data. Especcially it is working fine with MasterDetail part of SfDatagrid. Ok You're using RelationalColumn parameter, but that's logical. Why not in ComboboxColumn? I know it can be usefull, but shouldn't be a dead end.


Muthukumar Kalyanasundaram [Syncfusion]
Replied On September 5, 2017 03:52 PM UTC

Hi Marcin, 
Thanks for the update. 
We have created a new incident under your account related to this query. Please log on to our support website to check for further updates,  
Please let me know if you have any questions.  
Muthukumar K 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon