本文整理汇总了C#中TabControl.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# TabControl.ApplyTemplate方法的具体用法?C# TabControl.ApplyTemplate怎么用?C# TabControl.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabControl
的用法示例。
在下文中一共展示了TabControl.ApplyTemplate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: First_Tab_Should_Be_Selected_By_Default
public void First_Tab_Should_Be_Selected_By_Default()
{
TabItem selected;
var target = new TabControl
{
Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
Items = new[]
{
(selected = new TabItem
{
Name = "first",
Content = "foo",
}),
new TabItem
{
Name = "second",
Content = "bar",
},
}
};
target.ApplyTemplate();
Assert.Equal(0, target.SelectedIndex);
Assert.Equal(selected, target.SelectedItem);
}
示例2: 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);
}
示例3: 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());
}
示例4: Removal_Should_Set_Next_Tab
public void Removal_Should_Set_Next_Tab()
{
var collection = new ObservableCollection<TabItem>()
{
new TabItem
{
Name = "first",
Content = "foo",
},
new TabItem
{
Name = "second",
Content = "bar",
},
new TabItem
{
Name = "3rd",
Content = "barf",
},
};
var target = new TabControl
{
Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
Items = collection,
};
target.ApplyTemplate();
target.SelectedItem = collection[1];
collection.RemoveAt(1);
// compare with former [2] now [1] == "3rd"
Assert.Same(collection[1], target.SelectedItem);
}
示例5: ApplyTemplate
private void ApplyTemplate(TabControl target)
{
target.ApplyTemplate();
var carousel = (Carousel)target.Pages;
carousel.ApplyTemplate();
carousel.Presenter.ApplyTemplate();
var tabStrip = (TabStrip)target.TabStrip;
tabStrip.ApplyTemplate();
tabStrip.Presenter.ApplyTemplate();
}
示例6: SelectedContent_Should_Initially_Be_First_Tab_Content
public void SelectedContent_Should_Initially_Be_First_Tab_Content()
{
var target = new TabControl
{
Template = new ControlTemplate<TabControl>(this.CreateTabControlTemplate),
Items = new[]
{
new TabItem
{
Name = "first",
Content = "foo",
},
new TabItem
{
Name = "second",
Content = "bar",
},
}
};
target.ApplyTemplate();
Assert.Equal("foo", target.SelectedContent);
}
示例7: 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);
}
示例8: Non_IHeadered_Control_Items_Should_Be_Ignored
public void Non_IHeadered_Control_Items_Should_Be_Ignored()
{
var items = new[]
{
new TextBlock { Text = "foo" },
new TextBlock { Text = "bar" },
};
var target = new TabControl
{
Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
Items = items,
};
target.ApplyTemplate();
var result = target.TabStrip.GetLogicalChildren()
.OfType<TabStripItem>()
.Select(x => x.Content)
.ToList();
Assert.Equal(new object[] { string.Empty, string.Empty }, result);
}
示例9: Setting_SelectedTab_Should_Set_SelectedItem
public void Setting_SelectedTab_Should_Set_SelectedItem()
{
var target = new TabControl
{
Template = ControlTemplate.Create<TabControl>(this.CreateTabControlTemplate),
Items = new[]
{
new TabItem
{
Name = "first"
},
new TabItem
{
Name = "second"
},
}
};
target.ApplyTemplate();
target.SelectedTab = target.Items.Cast<TabItem>().ElementAt(1);
Assert.Same(target.SelectedItem, target.SelectedTab);
}