wpf - Grouping and sorting for TreeView in xaml -


I'm having trouble grouping my head and sorting in janabhabe and hopefully someone can get me straight out !

I have created an XML file from a tree of files and folders (just like the windows explorer) which can be several levels deep I've bound a TreeView control on an XMLView data source and it's pretty good Works! It does everything alphabetically ... but I would like to sort it all the folders first, instead of the folders listed with the files, as it is now.

xml:

If you load it in a tree, it will display the first two files of the folder because they are in alpha order first.

Here's my code:

  & lt;! - Will contain XML-data - - & gt; & Lt; XmlDataProvider x: key = "xmlDP" XPath = "*" & gt; & Lt; X: XData & gt; & Lt; Select_Project / & gt; & Lt; / X: XData & gt; & Lt; / XmlDataProvider & gt; & Lt ;! - This hierarchical data plate is all XML-nodes - & gt; & Lt; Hierarchical dataTypeplate dataType = "project" item source = "{binding}" & gt; & Lt; Text block text = "{binding XPath = @ name}" /> & Lt; / HierarchicalDataTemplate & gt; & Lt; Hierarchical datatypeplate dataType = "folder" item source = "{binding}" & gt; & Lt; Text block text = "{binding XPath = @ name}" /> & Lt; / HierarchicalDataTemplate & gt; & Lt; Hierarchical Datatypeplate DataType = "File" ItemSource = "{Binding}" & gt; & Lt; Text block text = "{binding XPath = @ name}" /> & Lt; / HierarchicalDataTemplate & gt; & Lt; Collection view support X: key = "project view" source = "{static resource xlp}" & gt; & Lt; CollectionViewSource.SortDescriptions & gt; & Lt ;! - Add Details Description - & gt; & Lt; /CollectionViewSource.SortDescriptions> & Lt; / CollectionViewSource & gt; & Lt; Tree View Margin = "11,79.992,18,19.089" name = "TVProject" bordertyxize = "1" fontisystem = "12" fontfamily = "wordana" & gt; & Lt; Trivium item source = "{binding source = {static resource xlp}, expat = *}" header = "project" /> & Lt; / TreeView & gt; Try adding another attribute to your XML file, I'll type it in the file, but whatever you call it to your liking, specify this to be equal to "folder" or "file" for this element. Now you can sort Should be at the level. Sort the first sort on file type (folder first, files second), then sort on name attribute. In other words, you want XML like this:  
  & lt; Project Name = "Project Name" & gt; & Lt; File name = "alphacat.html" file type = "file" /> & Lt; File name = "aztec.html" file type = "file" /> & Lt; Folder name = "folder" file type = "folder" & gt; & Lt; File name = "application.asp" file type = "file" /> & Lt; File name = "work.asp" file type = "file" /> & Lt; / Folder & gt; & Lt; / Project & gt;  

Does that help?


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -