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

Auto generated column complex objects

Thread ID:





124760 Jun 28,2016 09:14 AM UTC Jun 29,2016 01:40 PM UTC WPF 1
Tags: SfDataGrid
Leclerc Alexandre
Asked On June 28, 2016 09:14 AM UTC

Hello Syncfusion,

I have an app who manages objects to display in datagrid with MVVM in wpf.
The ViewModel is generic and feed the datagrid according the Model type.
The columns are auto generated and I use the annotations to set the display. So far so good.

It blocks when I have complex objects encapsulated in Model.
For example I have a Family object who contains a GroupFamily object. I try to display it like a text, and display it like a combobox for edit.
I used GridTemplateColumn for the example. Like this :

                        <syncfusion:GridTemplateColumn HeaderText="Family Group" MappingName="Group">
                                    <TextBlock VerticalAlignment="Center" Text="{Binding Path=Group.Name}" />
                                    <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},
                                              SelectedValue="{Binding Path=Group}"/>

But it not matches with what I'm looking for. I want to display for any complex object this template. How can I do ?
Remain that Model can encapsulate few complex objects.

Thanks for your answer.

Jai Ganesh S [Syncfusion]
Replied On June 29, 2016 01:40 PM UTC

Hi Leclerc, 
We suspect that you want to bind the complex objects in a column and bind the combobox SelectedItem based on the object. We have prepared the sample based on this and please find the sample from the below location, 
   <syncfusion:GridTemplateColumn Width="140" 
                                 MappingName="Customers" > 
                        <TextBlock Text="{Binding Path=Customers.City}"/> 
                        <ComboBox  ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, 
                                                            Path=DataContext.CompanyItems}" SelectedItem="{Binding Path=Customers.City}" /> 
In the above sample, we have a combobox’s ItemsSource in a viewmodel and bind the SelectedItem based on the complex property. 
If we misunderstood your requirement, please share the more details about your requirement? This would be more helpful for us to analyze further. 
Jai Ganesh S 


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