本文整理汇总了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);
}
示例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());
}
示例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);
}