我有简单的类(class)
public class Person
{
string Name { get; set; }
string Path { get; set; }
}
我还有 System.Windows.Controls.ListView 包含几个这种类型的对象。
我想在此 ListView 中显示这两个属性(或更多属性)。
如果我知道我可以使用 DisplayMemberPath 来做到这一点:
<ListView DisplayMemberPath="Name" Name="listViewClients" />
但是我怎样才能得到这样的结果:
"Name: Path"
(我的意思当然是适当对象的此属性值)
最佳答案
一种方法是创建另一个只读属性来包装它们。
string NamePath { get { return Name + ": " + Path; }}
然后您可以将 DisplayMemberPath 设置为 NamePath
关于c# - ListView 中多个属性的 DisplayMemberPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7417604/