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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to bind a ComboBox in a DetailView Template in C#

Thread ID:





140773 Nov 6,2018 10:18 PM UTC Nov 8,2018 06:17 AM UTC WPF 1
Tags: SfDataGrid
Patrick Feusi
Asked On November 6, 2018 10:33 PM UTC


is it possible to bind a ComboBoxAdv in DetailView Template of a SfDataGrid with C#?


Deivaselvan Y [Syncfusion]
Replied On November 8, 2018 06:17 AM UTC

Hi Patrick, 

Thank you for contacting Syncfusion support. 

We have analyzed your query “To bind ComboBoxAdv in DetailsViewTemplate with C#”. You can achieve your requirement by using the below code snippet 

public class SfDataGridBehavior: Behavior<SfDataGrid> 
        protected override void OnAttached() 
            TemplateViewDefinition templateViewDefinition = new TemplateViewDefinition(); 
            templateViewDefinition.RowTemplate = GetDataTemplate(); 
        private DataTemplate GetDataTemplate() 
            FrameworkElementFactory comboBoxAdv = new FrameworkElementFactory(typeof(ComboBoxAdv)); 
            comboBoxAdv.SetValue(ComboBoxAdv.HorizontalAlignmentProperty, HorizontalAlignment.Center); 
            comboBoxAdv.SetValue(ComboBoxAdv.VerticalAlignmentProperty, VerticalAlignment.Center); 
            comboBoxAdv.SetValue(ComboBoxAdv.SelectedValueProperty, "ProductName"); 
            comboBoxAdv.SetValue(ComboBoxAdv.DisplayMemberPathProperty, "ProductName"); 
           comboBoxAdv.SetValue(ComboBoxAdv.WidthProperty, 200d); 
            Binding binding = new Binding(); 
            binding.Path = new PropertyPath("DataContext.OrderList"); 
            binding.ElementName = this.AssociatedObject.Name; 
            comboBoxAdv.SetBinding(ComboBoxAdv.ItemsSourceProperty, binding);  
            var dataTemplate = new DataTemplate() { VisualTree = comboBoxAdv }; 
            return dataTemplate; 

Please find sample for the same from below link and let us know if this helps you. 



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

Live Chat Icon For mobile
Live Chat Icon