[英]binding a list of class to a data grid UWP
我想在數據網格中顯示這個對象(節點)(坐標是自定義 class 字面描述坐標) -
public class Node
{
[JsonRequired]
private bool finished;
[JsonRequired]
private readonly string type;
[JsonRequired]
private coordinate starting_point = null;
[JsonRequired]
private string ID = "";
[JsonRequired]
public coordinate Final_Dest = null;
[JsonRequired]
public List<coordinate> check_points = new List<coordinate>();
[JsonRequired]
private string Metadata = "";
[JsonRequired]
private readonly SimpleMarkerSymbol symbol;
[JsonRequired]
private int Vmax;
[JsonRequired]
public int Amax;
[JsonRequired]
private int slope_max;
[JsonRequired]
private int slope_min;
[JsonRequired]
private int terrein_rank_reject;
[JsonRequired]
private int affinity_to_stay_in_group;
[JsonRequired]
public int GroupID;
[JsonRequired]
public bool coomplitionflag = false;
這就是我試圖做的 -
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
selected_nodes = (comboclass)e.Parameter;
postioning_index = selected_nodes.Get_index();
Node[] array_of_nodes = selected_nodes.Get_node_array();
dataGrid.ItemsSource = Create_list(array_of_nodes);//this function creates a list of nodes
}
public static List<Node> Create_list(Node[] array_nodes)
{
var node_coll = new List<Node>();
for (int i = 0; i < array_nodes.Length; i++)
{
node_coll.Add(array_nodes[i]);
}
return node_coll;
}
並且由於某種原因,當我執行它時,它只在數據網格上顯示 field -type
將 class 列表綁定到數據網格 UWP
如果要綁定Node
實例,則需要實現公共字段的 set get 方法。
請編輯您的 class,如下所示。
public class Node
{
public string Title { get; set; }
public coordinate Final_Dest { get; set; }
.......
}
有關更多詳細信息,請參閱數據綁定深度文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.