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

Detail view Columns binding


I'm binding Columns collection to the view model based on this article: https://help.syncfusion.com/wpf/sfdatagrid/mvvm#bind-columns-from-viewmodel. I want to use it also for detail grid in master-detail setup. It works fine for master grid, but detail grid has always no columns.

Is there a way how to do it?



4 Replies

OS Ondrej Svoboda June 5, 2019 09:27 AM UTC

Just to clarify what I need: dynamically change detail grid column setup (add, remove, reorder columns) from view model.

AK Adhikesevan Kothandaraman Syncfusion Team June 5, 2019 10:19 AM UTC

Hi Ondra, 

Thanks for using Syncfusion products. 

We are currently analyzing your reported query at our end. We will get back to you with the complete details on this at 7th June, 2019. Meanwhile, If you want to populate the details view grid columns, you can use the AutoGenerateColumns property as true for the details view grid or  manually defining the columns for the details view grid. Refer to the following UG link for defining the columns for the master details view grid, 


OS Ondrej Svoboda June 27, 2019 07:33 AM UTC

anything new regarding this topic?


AK Adhikesevan Kothandaraman Syncfusion Team June 27, 2019 12:23 PM UTC

Hi Ondre, 

Regret for the inconvenience caused. 

Since the details view grid is not available in the visual tree, it will not support the binding. Therefore, it will not directly bind to the ViewModel property.  
If you want to bind the columns collection of the DetailsViewDataGrid with ViewModel property, you can use the binding by inheriting Freezable class as below, 
Code Snippet: 
public class BindingProxy : Freezable 
    protected override Freezable CreateInstanceCore() 
        return new BindingProxy(); 
    public object Data 
        get { return (object)GetValue(DataProperty); } 
        set { SetValue(DataProperty, value); } 
    public static readonly DependencyProperty DataProperty = 
        DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null)); 
And you can bind to the Columns property of columns in DetailsViewDataGrid as like below, 
    <local:BindingProxy x:Key="proxy" Data="{Binding DataContext, ElementName=datagrid}"/> 
    <Syncfusion:GridViewDefinition RelationalColumn="EmployeeDetails"> 
            <Syncfusion:SfDataGrid x:Name="FirstDetailsViewDataGrid" AutoGenerateColumns="False"  
                                   Columns="{Binding Data.SfGridColumns, Source={StaticResource proxy}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">                            


Live Chat Icon For mobile
Up arrow icon