且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将xml绑定到wpf,mvvm中的treeview控件

更新时间:2022-10-14 17:57:14

我认为这会有所帮助:





http://www.codeproject.com/Articles/26288/Simplifying-the-WPF-TreeView-by-Using- the-ViewMode





http://www.codeproject.com/Articles/317766/Displaying-XML-in-a-WPF -TreeView

I have a xml with the format as shown below

<Targets>
  <Target Name="Target01">
    <Recipes>
      <RecipeFamilies>
        <RecipeFaimily>
          <Property ID="Name">RecipeFamily1</Property>
          <RecipeGroups>
            <RecipeGroup>
              <Property ID="Name">RecipeGroup1</Property>
            </RecipeGroup>
          </RecipeGroups>
        </RecipeFaimily>
        <RecipeFaimily>
          <Property ID="Name">RecipeFamily2</Property>
          <RecipeGroups>
            <RecipeGroup>
              <Property ID="Name">RecipeGroup1</Property>
            </RecipeGroup>
          </RecipeGroups>
        </RecipeFaimily>
      </RecipeFamilies>
    </Recipes>
  </Target>
</Targets>



I want bind this to a tree view control in WPF, MVVM. Using HierarchicalDataTemplate I was able to show only one level of child node, but I was not able to show next level of child nodes.

I think this would help:


http://www.codeproject.com/Articles/26288/Simplifying-the-WPF-TreeView-by-Using-the-ViewMode


http://www.codeproject.com/Articles/317766/Displaying-XML-in-a-WPF-TreeView