本文介绍了将xml绑定到wpf,mvvm中的treeview控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个xml格式如下所示 < 目标 > < 目标 名称 = Target01 > < 食谱 > < RecipeFamilies > < RecipeFaimily > < Property ID = 名称 > RecipeFamily1 < / Property > < RecipeGroups > < RecipeGroup > < 属性 ID = 名称 > RecipeGroup1 < / Prop erty > < / RecipeGroup > < / RecipeGroups > < / RecipeFaimily > < RecipeFaimily > < 属性 ID = 名称 > RecipeFamily2 < / Property > < RecipeGroups > < RecipeGroup > < 属性 ID = 名称 > RecipeGroup1 < / Property > < / RecipeGroup > < / RecipeGroups > < / RecipeFaimily > < / RecipeFamilies > < / Recipes > < / Target > < / Targets > 我希望将它绑定到WPF,MVVM中的树视图控件。使用HierarchicalDataTemplate我只能显示一个级别的子节点,但我无法显示下一级子节点。解决方案 我认为这会有所帮助: 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-ViewModehttp://www.codeproject.com/Articles/317766/Displaying-XML-in-a-WPF-TreeView 这篇关于将xml绑定到wpf,mvvm中的treeview控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 05:41