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


C# TabControl.GetLogicalChildren方法代码示例

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


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

示例1: Logical_Child_Should_Be_SelectedContent

        public void Logical_Child_Should_Be_SelectedContent()
        {
            var target = new TabControl
            {
                Template = new ControlTemplate<TabControl>(this.CreateTabControlTemplate),
                Items = new[]
                {
                    new TabItem
                    {
                        Content = "foo"
                    },
                    new TabItem
                    {
                        Content = "bar"
                    },
                },
            };

            target.ApplyTemplate();

            Assert.Equal(1, target.GetLogicalChildren().Count());
            Assert.Equal("foo", ((TextBlock)target.GetLogicalChildren().First()).Text);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:23,代码来源:TabControlTests.cs

示例2: Logical_Children_Should_Be_TabItems

        public void Logical_Children_Should_Be_TabItems()
        {
            var items = new[]
            {
                new TabItem
                {
                    Content = "foo"
                },
                new TabItem
                {
                    Content = "bar"
                },
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                Items = items,
            };

            Assert.Equal(items, target.GetLogicalChildren());
            target.ApplyTemplate();
            Assert.Equal(items, target.GetLogicalChildren());
        }
开发者ID:abdelkarim,项目名称:Perspex,代码行数:24,代码来源:TabControlTests.cs

示例3: DataContexts_Should_Be_Correctly_Set

        public void DataContexts_Should_Be_Correctly_Set()
        {
            var items = new object[]
            {
                "Foo",
                new Item("Bar"),
                new TextBlock { Text = "Baz" },
                new TabItem { Content = "Qux" },
                new TabItem { Content = new TextBlock { Text = "Bob" } }
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                DataContext = "Base",
                DataTemplates = new DataTemplates
                {
                    new FuncDataTemplate<Item>(x => new Button { Content = x })
                },
                Items = items,
            };

            target.ApplyTemplate();

            var dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal(items[0], dataContext);

            target.SelectedIndex = 1;
            dataContext = ((Button)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal(items[1], dataContext);

            target.SelectedIndex = 2;
            dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Base", dataContext);

            target.SelectedIndex = 3;
            dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Qux", dataContext);

            target.SelectedIndex = 4;
            dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Base", dataContext);
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:43,代码来源:TabControlTests.cs


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