当前位置: 首页>>代码示例>>C#>>正文


C# TreeView.ApplyTemplate方法代码示例

本文整理汇总了C#中TreeView.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.ApplyTemplate方法的具体用法?C# TreeView.ApplyTemplate怎么用?C# TreeView.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeView的用法示例。


在下文中一共展示了TreeView.ApplyTemplate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Root_ItemContainerGenerator_Containers_Should_Be_Root_Containers

        public void Root_ItemContainerGenerator_Containers_Should_Be_Root_Containers()
        {
            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                Items = CreateTestTreeData(),
                DataTemplates = CreateNodeDataTemplate(),
            };

            target.ApplyTemplate();

            var container = (TreeViewItem)target.ItemContainerGenerator.Containers.Single();
            var header = (TextBlock)container.Header;
            Assert.Equal("Root", header.Text);
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:15,代码来源:TreeViewTests.cs

示例2: Items_Should_Be_Created

        public void Items_Should_Be_Created()
        {
            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                Items = CreateTestTreeData(),
                DataTemplates = CreateNodeDataTemplate(),
            };

            target.ApplyTemplate();

            Assert.Equal(new[] { "Root" }, ExtractItemHeader(target, 0));
            Assert.Equal(new[] { "Child1", "Child2" }, ExtractItemHeader(target, 1));
            Assert.Equal(new[] { "Grandchild2a" }, ExtractItemHeader(target, 2));
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:15,代码来源:TreeViewTests.cs

示例3: Control_Item_Should_Not_Be_NameScope

        public void Control_Item_Should_Not_Be_NameScope()
        {
            var items = new object[]
            {
                new TreeViewItem(),
            };

            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                Items = items,
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();

            var item = target.Presenter.Panel.LogicalChildren[0];
            Assert.Null(NameScope.GetNameScope((TreeViewItem)item));
        }
开发者ID:yusuf-gunaydin,项目名称:Avalonia,代码行数:19,代码来源:TreeViewTests.cs

示例4: ApplyTemplates

 private void ApplyTemplates(TreeView tree)
 {
     tree.ApplyTemplate();
     tree.Presenter.ApplyTemplate();
     ApplyTemplates(tree.Presenter.Panel.Children);
 }
开发者ID:randydotnet,项目名称:Perspex,代码行数:6,代码来源:TreeViewTests.cs

示例5: DataContexts_Should_Be_Correctly_Set

        public void DataContexts_Should_Be_Correctly_Set()
        {
            var items = new object[]
            {
                "Foo",
                new Node { Value = "Bar" },
                new TextBlock { Text = "Baz" },
                new TreeViewItem { Header = "Qux" },
            };

            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                DataContext = "Base",
                DataTemplates = new DataTemplates
                {
                    new FuncDataTemplate<Node>(x => new Button { Content = x })
                },
                Items = items,
            };

            target.ApplyTemplate();

            var dataContexts = target.Presenter.Panel.Children
                .Cast<Control>()
                .Select(x => x.DataContext)
                .ToList();

            Assert.Equal(
                new object[] { items[0], items[1], "Base", "Base" },
                dataContexts);
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:32,代码来源:TreeViewTests.cs

示例6: LogicalChildren_Should_Be_Set

        public void LogicalChildren_Should_Be_Set()
        {
            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                Items = new[] { "Foo", "Bar", "Baz " },
            };

            target.ApplyTemplate();

            var result = target.GetLogicalChildren()
                .OfType<TreeViewItem>()
                .Select(x => x.Header)
                .OfType<TextBlock>()
                .Select(x => x.Text)
                .ToList();

            Assert.Equal(new[] { "Foo", "Bar", "Baz " }, result);
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:19,代码来源:TreeViewTests.cs


注:本文中的TreeView.ApplyTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。