C# TreeView WPF绑定

C# TreeView WPF绑定,c#,wpf,treeview,C#,Wpf,Treeview,我正在使用TreeViewWPF。 我有以下课程: class MyFiles : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public string displayName; public string fullPath; public string DisplayName { get{return

我正在使用
TreeView
WPF。
我有以下课程:

class MyFiles : INotifyPropertyChanged
{
     public event PropertyChangedEventHandler PropertyChanged;
     public string displayName;
     public string fullPath;

     public string DisplayName
     {
         get{return displayName;}
         set{displayName = value; INofityPropertyChanged();}
     }
      public string FullName
     {
         get{return fullPath;}
         set{fullPath = value; INofityPropertyChanged();}
     }

     private void INofityPropertyChanged(string propertyName="")
     {
        if(propertyName != null && PropertyChanged != null)
             PropertyChanged (this, new PropertyChangedEventsArgs(propertyName);
     }
}
我想将该类绑定到TreeView。
我的尝试:

<TreeView Name=treeViewFiles>
    <TreeView.Resources>
            <HierarcjocalDataTemplate DataType="x:Static local:MyFiles" ItemSource="{Binding MyFiles}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text={Binding DisplayName}>
                    <TextBlock Text={Binding FullName}>
                </StackPanel>
            </HierarcjocalDataTemplate>
    <TreeView.Resources>
</TreeView>

.cs:

fileList = new ObservableCollection<MyFiles>();
fileList.Add(new MyFiles("Test","TestPath"));
treeViewFiles.ItemSource = fileList;
fileList=newobserveCollection();
添加(新的MyFiles(“Test”、“TestPath”);
treeViewFiles.ItemSource=文件列表;
我得到了类似于列表的东西,而不是树:\
如何修复代码以获得具有根等的真实树?

谢谢

当然,这将是一个简单的列表。项目不知道它们在层次结构中的位置。你的代码中也需要有一个树形结构,这还不清楚。你有多少等级?我只看到一个层面,为什么你需要一个树状视图?也许这会有帮助:你的INotifyPropertyChanged有用吗?我不这么认为。。。因为您没有提供属性名,所以每次属性名都应该为“”。也许你忘记添加[CallerMemberName]了?私有void INofityPropertyChanged([CallerMemberName]字符串propertyName=”“)