小编Kir*_*ill的帖子

C# ObservableCollection 不会出现在 MVVM 的 TreeView 中

所以我有一个集合NameCodeIdList与节点类型ServiceTypeDto这样的模式:

public class ServiceTypeDto
{
   public long Id
   public string Code
   public string Name
   public List<ServiceTypeDto> ChildrenList
}
Run Code Online (Sandbox Code Playgroud)

我有一个返回ServiceTypeDtos列表的方法,如下所示:

Dto列表

我有一个ChildernList暴露ServiceTypeDtos的。

这就是我尝试在ViewModel 中执行此操作的方式:

using System.Collections.Generic;
using System.Collections.ObjectModel;

using ServiceTypeService.Dto;
using ServiceTypeService.Interface;

using ShowServiceType.Interfaces;
using ShowServiceType.Utils;

namespace ShowServiceType.ViewModel
{
   class MainWindowViewModel : ViewModelBase
   {
      public string _name, _code;
      public long _id;
      public List<ServiceTypeDto> _childrenList = new List<ServiceTypeDto>();

      /// <summary>
      /// Create Services for work …
Run Code Online (Sandbox Code Playgroud)

c# wpf treeview mvvm visual-studio

0
推荐指数
1
解决办法
83
查看次数

标签 统计

c# ×1

mvvm ×1

treeview ×1

visual-studio ×1

wpf ×1