本文整理汇总了C#中ListBox.GetLogicalChildren方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.GetLogicalChildren方法的具体用法?C# ListBox.GetLogicalChildren怎么用?C# ListBox.GetLogicalChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox.GetLogicalChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogicalChildren_Should_Be_Set_For_DataTemplate_Generated_Items
public void LogicalChildren_Should_Be_Set_For_DataTemplate_Generated_Items()
{
var target = new ListBox
{
Template = new FuncControlTemplate(CreateListBoxTemplate),
Items = new[] { "Foo", "Bar", "Baz " },
};
target.ApplyTemplate();
Assert.Equal(3, target.GetLogicalChildren().Count());
foreach (var child in target.GetLogicalChildren())
{
Assert.IsType<ListBoxItem>(child);
}
}
示例2: LogicalChildren_Should_Be_Set_For_DataTemplate_Generated_Items
public void LogicalChildren_Should_Be_Set_For_DataTemplate_Generated_Items()
{
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
{
var target = new ListBox
{
Template = ListBoxTemplate(),
Items = new[] { "Foo", "Bar", "Baz " },
};
Prepare(target);
Assert.Equal(3, target.GetLogicalChildren().Count());
foreach (var child in target.GetLogicalChildren())
{
Assert.IsType<ListBoxItem>(child);
}
}
}
示例3: Setting_Item_IsSelected_Sets_ListBox_Selection
public void Setting_Item_IsSelected_Sets_ListBox_Selection()
{
var target = new ListBox
{
Template = new ControlTemplate(CreateListBoxTemplate),
Items = new[] { "Foo", "Bar", "Baz " },
};
target.ApplyTemplate();
((ListBoxItem)target.GetLogicalChildren().ElementAt(1)).IsSelected = true;
Assert.Equal("Bar", target.SelectedItem);
Assert.Equal(1, target.SelectedIndex);
}