wpfxamldevexpressxtratreelistdevexpress-wpf

The name"abc" doesnot exist in namespace "clr-namespace:abc"


I m trying to construct a tree in unbound mode devexpress control in wpf. I have reffered the following link Building a Tree in Unbound Mode . Please check the image , i m getting error in xaml code.The required output is that the hard coded data must appear in treelist but the output that appears is only a tree structure if i remove the xaml code from line 38-44 . I know that the error is in xaml still i m also providing cs code.

enter image description here

***************************Code*****************************************

 namespace PstImporter
  {
/// <summary>
/// Interaction logic for pstSelect.xaml
/// </summary>
public partial class pstSelect : Window
{
    string stgPath;
    public pstSelect ()
    {
        InitializeComponent();
        treePstSelect.Visibility = Visibility.Hidden;
        List < MailboxHelper.Folder > lstMailBoxHelper = Globals.selectFolder(fileName);
        buildTree(lstMailBoxHelper);
        treeListView1.ExpandAllNodes();
        this.barButtonItem1.ItemClick += this.barButtonItem1_ItemClick;
    }

    public class ProjectObject
    {
        public string Name { get; set; }
        public string Executor { get; set; }
    }

    private void buildTree (List<MailboxHelper.Folder> lstMailBoxHelper)
    {
        TreeListNode rootNode = CreateRootNode(new ProjectObject() { Name = lstMailBoxHelper[0].displayName, Executor = lstMailBoxHelper[1].displayName });
        TreeListNode childNode = CreateChildNode(rootNode, new ProjectObject() { Name = lstMailBoxHelper[2].displayName, Executor = lstMailBoxHelper[1].displayName });
        CreateChildNode(childNode, new ProjectObject() { Name = lstMailBoxHelper[3].displayName, Executor = lstMailBoxHelper[1].displayName });
    }

    private TreeListNode CreateRootNode(object dataObject)
    {
        TreeListNode rootNode = new TreeListNode(dataObject);
        treeListView1.Nodes.Add(rootNode);
        return rootNode;
    }

    private TreeListNode CreateChildNode (TreeListNode parentNode, object dataObject)
    {
        TreeListNode childNode = new TreeListNode(dataObject);
        parentNode.Nodes.Add(childNode);
        return childNode;
    }

Solution

  • You cannot refer to nested classes in xaml. Heres what MSDN says about nested classes

    http://msdn.microsoft.com/en-us/library/ms753379.aspx

    Your custom class must not be a nested class. Nested classes and the "dot" in their general CLR usage syntax interfere with other WPF and/or XAML features such as attached properties.

    you can take out your ProjectObject class out of Window class

    namespace PstImporter
      {
    
         public class ProjectObject
        {
            public string Name { get; set; }
            public string Executor { get; set; }
        }
      }
    

    Then you can refer to it

    xmlns:local="clr-namespace:PstImporter"
    
    <local:ProjectObject>