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.
Unfortunately, activation email could not send to your email. Please try again.

how to bind GridDataVisibleColumn from ObservableCollection programmatically?

Thread ID:

Created:

Updated:

Platform:

Replies:

117615 Nov 17,2014 06:15 AM Nov 18,2014 04:22 AM WPF 1
loading
Tags: GridDataControl
Shwe
Asked On November 17, 2014 06:15 AM

Hi,
          Could you tell me how to bind GridDataVisibleColumn from ObservableCollection<ColumnChooserItems> programmatically without using binding property in design view?

Thank you.

Saravanan M [Syncfusion]
Replied On November 18, 2014 04:22 AM

Hi Shwe,

 

Thank you for Contacting Syncfusion support,

 

We have analyzed your query. You can bind the GridDataVisiblecolumn in code behind instead of binding in XAML from ObservableCollection. Please refer the below code snippet.

 

Code Snippet[C#]:

ObservableCollection<GridDataVisibleColumn> _Columns;

ObservableCollection<GridDataVisibleColumn> Columns

{

            get { return _Columns; }

            set { _Columns = value; }

}

public ObservableCollection<GridDataVisibleColumn> GetColumns()

{

  var columns = new ObservableCollection<GridDataVisibleColumn>();

  columns.Add(new GridDataVisibleColumn() {MappingName="CustomerID" });

   return columns;

}

 

public MainWindow()

{

  InitializeComponent();

  Columns = GetColumns();

  syncgrid.VisibleColumns.Add(Columns[0]);

  syncgrid.VisibleColumns.Add(Columns[1])

}

 

We have prepared a sample based on this and you can download it form below location,

 

Sample Location: GridDataControl_Sample.zip

 

We have a SfDataGrid control like GridDataControl. But compare to GridDataControl, SfDataGrid having a better performance and flexibility. SfDataGrid assists you to create entirely customizable and highly interactive features used to display and manipulate the huge amount of data. So, we suggest you to use SfDataGrid instead of GridDataControl.

 

We have prepared a sample based on the same scenario in SfDataGrid and you can download it from below location.

 

Sample Location: SampleApplication.zip

 

Please let us know if you have any queries,

 

Regards,

Saravanan.M

 


CONFIRMATION

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.

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.

;