本文整理汇总了C#中ItemsControl.GetItemsHost方法的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl.GetItemsHost方法的具体用法?C# ItemsControl.GetItemsHost怎么用?C# ItemsControl.GetItemsHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemsControl
的用法示例。
在下文中一共展示了ItemsControl.GetItemsHost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItemsHostForItemsControl
public virtual void GetItemsHostForItemsControl()
{
ItemsControl control = new ItemsControl { ItemsSource = new[] { 1, 2, 3, 4 } };
Panel host = null;
TestAsync(
control,
() => host = control.GetItemsHost(),
() => Assert.IsNotNull(host, "ItemsHost not found!"));
}
示例2: GetItemsHostIsCorrectPanel
public virtual void GetItemsHostIsCorrectPanel()
{
string name = "DesiredPanel";
ItemsControl control = new ItemsControl { ItemsSource = new[] { 1, 2, 3, 4, 5 } };
Panel host = null;
XamlBuilder<ItemsPanelTemplate> builder = new XamlBuilder<ItemsPanelTemplate>
{
Children = new List<XamlBuilder>
{
new XamlBuilder<StackPanel> { Name = name }
}
};
control.ItemsPanel = builder.Load();
TestAsync(
control,
() => host = control.GetItemsHost(),
() => Assert.IsNotNull(host, "Failed to find ItemsHost!"),
() => Assert.AreEqual(name, host.Name, "ItemsHost name did not match!"));
}
示例3: GetItemsHostWithNoHost
public virtual void GetItemsHostWithNoHost()
{
ItemsControl control = new ItemsControl { ItemsSource = new[] { 1, 2, 3, 4, 5 } };
XamlBuilder<ControlTemplate> builder = new XamlBuilder<ControlTemplate>
{
AttributeProperties = new Dictionary<string, string> { { "TargetType", "ItemsControl" } },
Children = new List<XamlBuilder> { new XamlBuilder<TextBlock>() }
};
control.Template = builder.Load();
Panel host = null;
TestAsync(
control,
() => host = control.GetItemsHost(),
() => Assert.IsNull(host, "Should not have found ItemsHost!"));
}