【发布时间】:2021-08-27 14:45:01
【问题描述】:
我继承了一个使用 WPF 的旧项目。我们利用基础设施。 下面是一个组成的类结构:
public class DogsVM
{
public string ViewName { get; set; } = "My Dogs";
public List<Dog> Dogs { get; set; }
}
public class Dog
{
public string DogName { get; set; }
public string Description { get; set; }
}
我正在使用XamDataGrid 来显示我的数据。
XamDataGrid 上的当前数据源是DataSource="{Binding CollectionView}"。
当我输出字段时,我正在使用以下内容
<igDP:Field Name="DogName " Label="Dog Name" AllowEdit="False" />
我希望将标签更改为 DogsVM 并选择字段 ViewName
如果我这样做
<igDP:Field Name="DogName " Label="{Binding ViewName}" AllowEdit="False" />
DogName 输出为我正在查看Dog 对象,而不是DogsVM 对象。如何在标签绑定中到达父对象?
【问题讨论】:
-
这是一个简化的例子。标签将是动态创建的,而不是硬编码的字符串。
标签: wpf xaml infragistics legacy-code xamdatagrid