You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-3Lines changed: 48 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# How to bind the data table to WPF DataGrid
1
+
# How to Bind the DataTable to WPF DataGrid?
2
2
3
3
This sample show cases how to bind the data table to [WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid) (SfDataGrid).
4
4
@@ -15,6 +15,7 @@ public class ViewModel
15
15
{
16
16
DataTableCollection=GetDataTable();
17
17
}
18
+
18
19
publicDataTableDataTableCollection { get; set; }
19
20
20
21
privateDataTableGetDataTable()
@@ -51,7 +52,7 @@ public class ViewModel
51
52
52
53
### Binding ItemsSource in XAML
53
54
54
-
In the main page, add the necessary XML namespace to use `SfDataGrid` control, set the DataContext of the window to the `ViewModel` class, and bind the `ItemsSource` of `SfDataGrid` with the `DataTableCollection`.
55
+
In the main page, add the necessary XML namespace to use `DataGrid` control, set the DataContext of the window to the `ViewModel` class, and bind the `ItemsSource` of `DataGrid` with the `DataTableCollection`.
55
56
56
57
```xml
57
58
<Windowx:Class="SfDataGridDemo.MainWindow"
@@ -72,4 +73,48 @@ In the main page, add the necessary XML namespace to use `SfDataGrid` control, s

77
+
78
+
79
+
### CRUD operations
80
+
81
+
DataGrid automatically refreshes the UI whenever we add, delete or modify the rows of the underlying DataTable collection.
82
+
83
+
### Data operations
84
+
85
+
DataGrid supports various data operations to represent the data in it. The following are supported by default:
86
+
87
+
* Sorting (including multicolumn sorting)
88
+
* Grouping (including multicolumn grouping)
89
+
* Filtering
90
+
* Summaries
91
+
92
+
#### Sorting
93
+
94
+
You can sort columns with the various built-in options such as [multicolumn sorting](https://help.syncfusion.com/wpf/datagrid/sorting#multi-column-sorting) and [tri-state sorting](https://help.syncfusion.com/wpf/datagrid/sorting#sorting-order). But [custom sorting](https://help.syncfusion.com/wpf/datagrid/sorting#custom-sorting) is not supported.
95
+
96
+
In the following screenshot, the datagrid is sorted in ascending order with respect to the **Customer Name** column.
97
+
98
+

99
+
100
+
#### Grouping
101
+
102
+
The data can be organized in a hierarchical structure based on matching field values. [Custom grouping](https://help.syncfusion.com/wpf/datagrid/grouping#custom-grouping) are also supported.
103
+
104
+

105
+
106
+
#### Filtering
107
+
108
+
You can filter columns with the various built-in options such as [Excel like UI filtering](https://help.syncfusion.com/wpf/datagrid/filtering#excel-like-ui-filtering), [Advanced UI filtering](https://help.syncfusion.com/wpf/datagrid/filtering#advanced-filter-ui) and [Programmatic filtering](https://help.syncfusion.com/wpf/datagrid/filtering#column-filtering) by using [FilterPredicates](https://help.syncfusion.com/cr/cref_files/wpf/Syncfusion.SfGrid.WPF~Syncfusion.UI.Xaml.Grid.GridColumn~FilterPredicates.html). But DataGrid’s built-in [View.Filter](https://help.syncfusion.com/cr/wpf/Syncfusion.Data.CollectionViewAdv.html#Syncfusion_Data_CollectionViewAdv_Filter) is not supported for the DataTable class. But you can filter the records using DataTable's [DataView.RowFilter](https://docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter?view=netframework-4.8) property.
109
+
110
+

111
+
112
+
#### Summaries
113
+
114
+
All summary types supported by DataGrid are supported for DataTable, i.e. [group summary](https://help.syncfusion.com/wpf/datagrid/summaries#group-summary), [caption summary](https://help.syncfusion.com/wpf/datagrid/summaries#caption-summaries), and [table summary](https://help.syncfusion.com/wpf/datagrid/summaries#table-summary).
115
+
116
+
### Other features
117
+
118
+
The support for all other features, such as stacked headers, row drag and drop, unbound column, and unbound row, of DataGrid are available.
119
+
120
+
Take a moment to peruse the [WPF DataGrid - Overview](https://help.syncfusion.com/wpf/datagrid/overview) documentation, to learn more about the DataGrid's feature sets.
0 commit comments