I've create a treeview in c# like this code ,but
How can I do this in wpf (xaml); ?
C#
public void PopulateTreeView( string dirValue, TreeNode parentNode )
{
/* dirValue = inputTextBox.Text
parentNode = directoryTreeView.Nodes[0] ..
*
directoryTreeView is a Treeview
*/
// array stores all subdirectories in the directory
string[] directoryArray = Directory.GetDirectories( dirValue);
try
{
// subdirectories are present
if ( directoryArray.Length != 0 )
{
// create new TreeNode,
foreach ( string directory in directoryArray )
{
// substringDirectory is a string defined in generall
substringDirectory = Path.GetFileNameWithoutExtension(directory );
// current directory
TreeNode myNode = new TreeNode( substringDirectory );
// add current directory node to parent node
parentNode.Nodes.Add( myNode );
// recursive populate
PopulateTreeView( directory, myNode );
}
}
}
catch ( UnauthorizedAccessException )
{
parentNode.Nodes.Add( "Access denied !" );
}
}Code
please explain clearly or post a snippet code (cause I'm new in xaml). TanxCode
I've posted this question here but it doesn't help me.
Answers
Know the answer? Post it. Somebody with the same question will find it here.