Click here to Skip to main content
15,886,724 members
Articles / Web Development / HTML

WPF x FileExplorer x MVVM

Rate me:
Please Sign up or sign in to vote.
4.99/5 (52 votes)
24 Nov 2012LGPL323 min read 289.1K   9.4K   228  
This article describe how to construct FileExplorer controls included DirectoryTree and FileList, using Model-View-ViewModel (MVVM) pattern.
/*
 * Created by SharpDevelop.
 * User: LYCJ
 * Date: 19/10/2007
 * Time: 2:53
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;

namespace QuickZip.MiniHtml2
{
	/// <summary>
	/// Represent owner of all HtmlTag.
	/// </summary>
	public class HtmlTagTree : HtmlTagNode
	{
		public HtmlTagTree() : base(null, null)
		{
			isRoot = true;
			tag = new HtmlTag("master","");
		}
		
		public override bool CanAdd(HtmlTag aTag)
		{
			return true;
		}		
		
		static string printNode(Int32 level, HtmlTagNode node)
		{
			string spacing = " ";
			string retVal = "";
			for (int i = 0; i < level; i++)
				spacing += "  ";
			
			retVal += spacing + node.ToString() + '\r'+'\n';
			
			foreach (HtmlTagNode subnode in node)
				retVal += HtmlTagTree.printNode(level+1, subnode);			
			
			return retVal;
		}
		
		public override string ToString()
		{
			string retVal = "";
			
			foreach (HtmlTagNode subnode in this)
				retVal += HtmlTagTree.printNode(0, subnode);
			
			return retVal;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Founder
Hong Kong Hong Kong

Comments and Discussions