|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using System.Windows; |
| 7 | +using System.Windows.Controls; |
| 8 | +using System.Windows.Data; |
| 9 | +using System.Windows.Documents; |
| 10 | +using System.Windows.Input; |
| 11 | +using System.Windows.Media; |
| 12 | +using System.Windows.Media.Imaging; |
| 13 | +using System.Windows.Navigation; |
| 14 | +using System.Windows.Shapes; |
| 15 | +using System.Data; |
| 16 | +using Syncfusion.UI.Xaml.Grid; |
| 17 | + |
| 18 | +namespace NETCoreWPFDemo |
| 19 | +{ |
| 20 | + public partial class MainWindow : Window |
| 21 | + { |
| 22 | + public MainWindow() |
| 23 | + { |
| 24 | + InitializeComponent(); |
| 25 | + SfDataGrid dataGrid = new SfDataGrid() { Height = 550, Width = 600, ColumnSizer = GridLengthUnitType.Star }; |
| 26 | + dataGrid.ItemsSource = GetDataTable(); |
| 27 | + this.ROOT_Grid.Children.Add(dataGrid); |
| 28 | + } |
| 29 | + |
| 30 | + public DataTable GetDataTable() |
| 31 | + { |
| 32 | + DataTable employeeCollection = new DataTable(); |
| 33 | + var dt = DateTime.Now; |
| 34 | + |
| 35 | + employeeCollection.Columns.Add("EmployeeID", typeof(int)); |
| 36 | + employeeCollection.Columns[0].ColumnName = "Employee ID"; |
| 37 | + employeeCollection.Columns.Add("EmployeeName", typeof(string)); |
| 38 | + employeeCollection.Columns["EmployeeName"].ColumnName = "Employee Name"; |
| 39 | + employeeCollection.Columns.Add("CustomerID", typeof(string)); |
| 40 | + employeeCollection.Columns["CustomerID"].ColumnName = "Customer ID"; |
| 41 | + employeeCollection.Columns.Add("Country", typeof(string)); |
| 42 | + employeeCollection.Columns.Add("Date", typeof(DateTime)); |
| 43 | + |
| 44 | + employeeCollection.Rows.Add(1001, "Belgim", "YHGTR", "US", new DateTime(dt.Year, dt.Month, dt.Day)); |
| 45 | + employeeCollection.Rows.Add(1002, "Oliver", "LDON", "UK", new DateTime(dt.Year, dt.Month, dt.AddDays(-1).Day)); |
| 46 | + employeeCollection.Rows.Add(1003, "Bernald", "ALFKI", "US", new DateTime(dt.Year, dt.Month, dt.AddDays(-5).Day)); |
| 47 | + employeeCollection.Rows.Add(1004, "James", "YHGTR", "US", new DateTime(dt.Year, dt.Month, dt.AddDays(-1).Day)); |
| 48 | + employeeCollection.Rows.Add(1005, "Beverton", "BERGS", "Europe", new DateTime(dt.Year, dt.Month, dt.Day)); |
| 49 | + |
| 50 | + return employeeCollection; |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments