本文整理汇总了C#中System.Windows.Controls.TabControl.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# TabControl.SetBinding方法的具体用法?C# TabControl.SetBinding怎么用?C# TabControl.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TabControl
的用法示例。
在下文中一共展示了TabControl.SetBinding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TabItemGeneratorBehavior
//-------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------
#region Constructors
/// <summary>
/// Constructor
/// </summary>
/// <param name="tab">Reference to parent <see cref="TabControl"/>.</param>
private TabItemGeneratorBehavior(TabControl tab)
{
if (null == tab)
throw new ArgumentNullException("Only hosts of type TabControl are supported.");
_tabControl = tab;
_tabControl.Loaded += OnTabLoaded;
_tabControl.SetBinding(TabControl.SelectedItemProperty,
new Binding("SelectedTabItem") { Source = this });
}
示例2: ControlWithExistingBindingOnItemsSourceWithNullValueThrows
public void ControlWithExistingBindingOnItemsSourceWithNullValueThrows()
{
var tabControl = new TabControl();
Binding binding = new Binding("Enumerable");
binding.Source = new SimpleModel() { Enumerable = null };
tabControl.SetBinding(ItemsControl.ItemsSourceProperty, binding);
IRegionAdapter adapter = new TestableTabControlRegionAdapter();
try
{
var region = (MockRegion)adapter.Initialize(tabControl, "region");
Assert.Fail();
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(InvalidOperationException));
StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty.");
}
}