开发者

WPF: TreeViewItem move UP and DOWN

I am trying to move up and down the TreeViewItem on Selection. Tried all online forum but the suggest the way is not working for me. Can anyone help please. Below is the code I am writing for Treecreation.

XAML:

  <TreeView Name="treeFileSystem" TreeViewItem.Selected="TreeViewItemSelected">
      <TreeViewItem Header="Suite"  Name="MYTree" Tag="hi"  IsExpanded="True">
          <TreeViewItem    Name="treeFileSystem1" />                              
       </TreeViewItem>
  </TreeView>

CODE:

private void TestsTreeViewPageFunction_Loaded(object sender, RoutedEventArgs e)
        {
            this.MYTree.Items.Clear();

            this.MYTree.ContextMenu = AddContexMenu("Suite");

            for (int j = 1; j < 5; j++)
            {
                TreeViewItem Case = new TreeViewItem();

                Case.ContextMenu = AddContexMenu("Case");
                Cas开发者_JS百科e.Header = "Case "+j.ToString();
                Case.IsExpanded = true;
                for (int i = 0; i < 5; i++)
                {
                    Case.Items.Add(Trythis(i));
                }
                this.MYTree.Items.Add(Case);
            }

        }

private TreeViewItem Trythis(int i)
        {
            TreeViewItem Step = new TreeViewItem();

            Step.Header = "Steps " + i.ToString();
            Step.ContextMenu = AddContexMenu("Step");

            return Step;          
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜