This question is locked. New answers and comments are not allowed.
I created a 16299 UWP project and use DataView as DataGrid's ItemsSource, but the UI cannot show any data.
More information, please check my code sample:
<
my:RadDataGrid
x:Name
=
"dataGrid"
AutoGenerateColumns
=
"False"
>
</
my:RadDataGrid
>
public sealed partial class MainPage : Page
{
private ObservableCollection<
Dictionary
<string, string>> items = new ObservableCollection<
Dictionary
<string, string>>();
public ObservableCollection<
Dictionary
<string, string>> ItemDictionary
{
get
{
return items;
}
set
{
items = value;
}
}
public DataTable Items { get; set; }
public MainPage()
{
this.InitializeComponent();
CreateItems();
CreateTable();
}
private void CreateItems()
{
for (int i = 0; i <
5
; i++)
{
Dictionary<string, string> row = new Dictionary<
string
, string>();
row["A"] = "A" + i.ToString();
row["B"] = "B" + i.ToString();
row["C"] = "C" + i.ToString();
ItemDictionary.Add(row);
}
}
private void CreateTable()
{
Items = new DataTable();
if (ItemDictionary.Count == 0) return;
foreach (KeyValuePair<
string
, string> entry in ItemDictionary[0])
{
DataColumn column = new DataColumn(entry.Key);
Items.Columns.Add(column);
Telerik.UI.Xaml.Controls.Grid.DataGridTextColumn dgc = new Telerik.UI.Xaml.Controls.Grid.DataGridTextColumn();
dgc.Name = entry.Key;
dgc.Header = entry.Key;
dgc.PropertyName = entry.Key;
dataGrid.Columns.Add(dgc);
}
foreach (Dictionary<
string
, string> rowEntry in ItemDictionary)
{
DataRow row = Items.NewRow();
int col = 0;
foreach (KeyValuePair<
string
, string> entry in rowEntry)
{
row[entry.Key] = entry.Value;
}
Items.Rows.Add(row);
}
DataView dv = Items.DefaultView;
dataGrid.ItemsSource = dv;
}
}