您好,我遇到了 DevExpress 的 TreeListView 的问题
我有以下课程:
public class EmployeeBase
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Employee : EmployeeBase
{
public int ParentId { get; set; }
}
以下是我的 XAML:
<dxg:TreeListControl AutoPopulateColumns="True" ItemsSource="{Binding Employees}">
<dxg:TreeListControl.View>
<dxg:TreeListView KeyFieldName="Id" ParentFieldName="ParentId">
</dxg:TreeListView>
</dxg:TreeListControl.View>
</dxg:TreeListControl>
后面的代码:
public ObservableCollection<EmployeeBase> Employees { get; set; }
public MainWindow()
{
InitializeComponent();
DataContext = this;
Employees = new ObservableCollection<EmployeeBase>(Rep.GetStuff());
}
当我运行应用程序时,treelistview 显示没有子对象的对象
如果我将 Observable 集合的类型更改为 Employee 而不是employee base,则子节点将正常生成。
有没有办法在不将 ParentId 属性添加到基类的情况下解决这个问题?