本文整理汇总了C#中TabItem.GetTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# TabItem.GetTemplate方法的具体用法?C# TabItem.GetTemplate怎么用?C# TabItem.GetTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabItem
的用法示例。
在下文中一共展示了TabItem.GetTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHeadersSizeTest
public void GetHeadersSizeTest()
{
TabControl tabControl = new TabControl();
tabControl.Height = 100;
tabControl.Width = 200;
double[] sizes = new double[3];
TabItem tabItem1 = new TabItem();
tabItem1.Height = 10;
tabItem1.Width = 10;
TabItem tabItem2 = new TabItem();
tabItem2.Height = 10;
tabItem2.Width = 20;
TabItem tabItem3 = new TabItem();
tabItem3.Height = 10;
tabItem3.Width = 30;
tabControl.Items.Add(tabItem1);
tabControl.Items.Add(tabItem2);
tabControl.Items.Add(tabItem3);
FrameworkElement fe = null;
double selectedMarginSize = 0;
CreateAsyncTask(tabControl,
() => sizes = tabControl.ElementTabPanelTop.GetHeadersSize(),
// First Item Is Selected
() => fe = (tabItem1.GetTemplate(tabItem1.IsSelected, tabItem1.TabStripPlacement) as Panel).Children[0] as FrameworkElement,
() => selectedMarginSize += (Math.Abs(fe.Margin.Left + fe.Margin.Right)),
() => Assert.AreEqual(sizes[0], 10.0 + selectedMarginSize),
() => Assert.AreEqual(sizes[1], 20.0),
() => Assert.AreEqual(sizes[2], 30.0)
);
EnqueueTestComplete();
}
示例2: UpdateVisualStateTest
public void UpdateVisualStateTest()
{
TabControl tabControl = new TabControl();
TabItem tabItem = new TabItem();
tabControl.Items.Add(tabItem);
tabItem.IsSelected = true;
tabControl.TabStripPlacement = Dock.Top;
tabItem.UpdateVisualState();
Assert.AreEqual(tabItem.ElementTemplateTopSelected, tabItem.GetTemplate(tabItem.IsSelected, tabItem.TabStripPlacement));
tabControl.TabStripPlacement = Dock.Bottom;
tabItem.UpdateVisualState();
Assert.AreEqual(tabItem.ElementTemplateBottomSelected, tabItem.GetTemplate(tabItem.IsSelected, tabItem.TabStripPlacement));
tabControl.TabStripPlacement = Dock.Left;
tabItem.UpdateVisualState();
Assert.AreEqual(tabItem.ElementTemplateLeftSelected, tabItem.GetTemplate(tabItem.IsSelected, tabItem.TabStripPlacement));
tabControl.TabStripPlacement = Dock.Right;
tabItem.UpdateVisualState();
Assert.AreEqual(tabItem.ElementTemplateRightSelected, tabItem.GetTemplate(tabItem.IsSelected, tabItem.TabStripPlacement));
}