本文整理汇总了C#中System.Windows.Controls.ListBox.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.Insert方法的具体用法?C# ListBox.Insert怎么用?C# ListBox.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ListBox
的用法示例。
在下文中一共展示了ListBox.Insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingleSelect_ModifySelectedItems_ChangedAnyway
public void SingleSelect_ModifySelectedItems_ChangedAnyway ()
{
var items = new ListBox ().SelectedItems;
Assert.Throws<InvalidOperationException> (() => items.Add (1), "#1");
Assert.AreEqual (1, items.Count, "#2");
Assert.Throws<InvalidOperationException> (() => items.Clear (), "#3");
Assert.AreEqual (0, items.Count, "#4");
Assert.Throws<InvalidOperationException> (() => items.Insert (0, 15), "#5");
Assert.AreEqual (1, items.Count, "#6");
}
示例2: MultiSelect_ModifySelectedItems_InvalidItems
public void MultiSelect_ModifySelectedItems_InvalidItems ()
{
var items = new ListBox { SelectionMode = SelectionMode.Multiple }.SelectedItems;
items.Add (1);
Assert.AreEqual (1, items.Count, "#1");
items.Clear ();
Assert.AreEqual (0, items.Count, "#2");
items.Insert (0, 15);
Assert.AreEqual (1, items.Count, "#3");
}
示例3: SingleSelect_ModifySelectedItems
public void SingleSelect_ModifySelectedItems ()
{
var items = new ListBox ().SelectedItems;
Assert.Throws<InvalidOperationException> (() => items.Add (1), "#1");
Assert.Throws<InvalidOperationException> (() => items.Clear (), "#2");
Assert.Throws<InvalidOperationException> (() => items.Insert (0, 15), "#3");
}