对于那些想知道的人来说,这是在自稳定算法工具的背景下。
假设我有几个类,Algorithm
, Rule
, Predicate
, Action
, Graph
, 和Node
, 定义如下:
using System;
using System.Collections.Generic;
using System.Text;
namespace SMP {
class Algorithm {
public List<Rule> Rules { get; set; }
public Algorithm() {
Rules = new List<Rule>();
}
}
class Rule {
public Predicate Predicate { get; set; }
public Action Action { get; set; }
}
class Predicate {
public string Description { get; set; }
public string Name { get; set; }
public string Expression { get; set; }
}
class Action {
public string Description { get; set; }
public string Name { get; set; }
public string Expression { get; set; }
}
}
我想连接一个两列ListView
,它将显示Predicate.Name
和Action.Name
为 some 中的每个元素Algorithm.Rules
。
请注意我在这篇文章中使用的以下变量名称:
ListView algorithm_view;
Algorithm algorithm
我知道我必须将DataContext
of设置algorithm_view
为我的Algorithm
实例algorithm_view.DataContext = algorithm
,但我不知道如何在 XAML 中表达这样的集合的绑定。
如果它有助于描绘它,这里是界面的截图: