本文整理汇总了C#中Eto.Forms.DynamicLayout.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicLayout.Clear方法的具体用法?C# DynamicLayout.Clear怎么用?C# DynamicLayout.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eto.Forms.DynamicLayout
的用法示例。
在下文中一共展示了DynamicLayout.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddingItemShouldSetChildrenAndParent
public void AddingItemShouldSetChildrenAndParent()
{
TestBase.Invoke(() =>
{
var layout = new DynamicLayout();
var items = new Control[] { new Label { ID = "label" }, new Button(), new TextBox() };
foreach (var item in items)
layout.Add(item);
CollectionAssert.AreEqual(items, layout.Children, "#1. Items do not match");
foreach (var item in items)
Assert.AreEqual(layout, item.Parent, "#2. Items should have parent set to dynamic layout");
Assert.AreSame(layout.FindChild<Label>("label"), items[0], "#3. FindChild should work without loading the dynamic layout");
layout.Clear();
foreach (var item in items)
Assert.IsNull(item.Parent, "#4. Items should have parent removed when removed from dynamic layout");
});
}
示例2: AddingItemMultipleLevelsDeepShouldSetChildrenAndParent
public void AddingItemMultipleLevelsDeepShouldSetChildrenAndParent()
{
TestBase.Invoke(() =>
{
var layout = new DynamicLayout();
var items = new List<Control>();
layout.BeginHorizontal();
Control ctl = new Button();
items.Add(ctl);
layout.Add(ctl);
layout.BeginVertical();
ctl = new Label();
items.Add(ctl);
layout.Add(ctl);
layout.EndVertical();
layout.EndHorizontal();
ctl = new TextBox();
items.Add(ctl);
layout.Add(ctl);
CollectionAssert.AreEqual(items, layout.Children, "#1. Items do not match");
foreach (var item in items)
Assert.AreEqual(layout, item.Parent, "#2. Items should have parent set to dynamic layout");
layout.Clear();
foreach (var item in items)
Assert.IsNull(item.Parent, "#3. Items should have parent removed when removed from dynamic layout");
});
}