本文整理汇总了C#中CollectionView.MoveCurrentToPosition方法的典型用法代码示例。如果您正苦于以下问题:C# CollectionView.MoveCurrentToPosition方法的具体用法?C# CollectionView.MoveCurrentToPosition怎么用?C# CollectionView.MoveCurrentToPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectionView
的用法示例。
在下文中一共展示了CollectionView.MoveCurrentToPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserControl_Loaded
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
DependencyPropertyDescriptor
.FromProperty(ButtonProfileProperty, typeof (ButtonMappingEntryControl))
.AddValueChanged(this, (s, args) =>
{
if (ButtonProfile == null) return;
CurrentCommandTypeView = new CollectionView(AvailableCommandTypes);
CurrentCommandTypeView.MoveCurrentToPosition((int) ButtonProfile.MappingTarget.CommandType);
switch (ButtonProfile.MappingTarget.CommandType)
{
case CommandType.GamepadButton:
CurrentCommandTargetView = new CollectionView(AvailableGamepadButtons);
CurrentCommandTargetView.MoveCurrentTo(ButtonProfile.MappingTarget.CommandTarget);
break;
case CommandType.Keystrokes:
CurrentCommandTargetView = new CollectionView(AvailableKeys);
CurrentCommandTargetView.MoveCurrentTo(
AvailableKeys.FirstOrDefault(
k => k == ToVirtualKeyCode(ButtonProfile.MappingTarget.CommandTarget)));
break;
// TODO: implement!
case CommandType.MouseButtons:
CurrentCommandTargetView = new CollectionView(AvailableMouseButtons);
break;
}
CurrentCommandTypeView.CurrentChanged += CurrentCommandTypeOnCurrentChanged;
CurrentCommandTargetView.CurrentChanged += CurrentCommandTargetOnCurrentChanged;
});
}
示例2: MoveCurrentToPosition
private void MoveCurrentToPosition(CollectionView cv, int position)
{
if (cv != null && IsSynchronizedWithCurrentItemInternal)
{
cv.MoveCurrentToPosition(position);
}
}
示例3: MoveCurrentToPosition_Throws_Exception_For_Past_End_Index
public void MoveCurrentToPosition_Throws_Exception_For_Past_End_Index()
{
List<int> source = new List<int> { 1, 2, 3 };
CollectionView target = new CollectionView(source);
target.MoveCurrentToPosition(4);
}
示例4: CurrentChanged_Should_Be_Raised_Even_If_Position_Doesnt_Change
public void CurrentChanged_Should_Be_Raised_Even_If_Position_Doesnt_Change()
{
List<int> source = new List<int> { 1, 2, 3 };
CollectionView target = new CollectionView(source);
bool eventRaised = false;
target.CurrentChanged += (s, e) => eventRaised = true;
target.MoveCurrentToPosition(0);
Assert.IsTrue(eventRaised);
}
示例5: MoveCurrentToPosition_Returns_False_For_After_End_Index
public void MoveCurrentToPosition_Returns_False_For_After_End_Index()
{
List<int> source = new List<int> { 1, 2, 3 };
CollectionView target = new CollectionView(source);
Assert.IsFalse(target.MoveCurrentToPosition(3));
Assert.IsNull(target.CurrentItem);
Assert.AreEqual(3, target.CurrentPosition);
Assert.IsFalse(target.IsCurrentBeforeFirst);
Assert.IsTrue(target.IsCurrentAfterLast);
}
示例6: MoveCurrentToPosition_Minus_1_Can_Be_Cancelled
public void MoveCurrentToPosition_Minus_1_Can_Be_Cancelled()
{
List<int> source = new List<int> { 1, 2, 3 };
CollectionView target = new CollectionView(source);
target.CurrentChanging += (s, e) => e.Cancel = true;
Assert.IsTrue(target.MoveCurrentToPosition(-1));
Assert.AreEqual(1, target.CurrentItem);
Assert.AreEqual(0, target.CurrentPosition);
Assert.IsFalse(target.IsCurrentBeforeFirst);
}
示例7: MoveCurrentToPosition_Returns_True_When_Item_Available
public void MoveCurrentToPosition_Returns_True_When_Item_Available()
{
List<int> source = new List<int> { 1, 2, 3 };
CollectionView target = new CollectionView(source);
Assert.IsTrue(target.MoveCurrentToPosition(1));
Assert.AreEqual(2, target.CurrentItem);
Assert.AreEqual(1, target.CurrentPosition);
}
示例8: MoveCurrentToPosition_Returns_False_For_Empty_Collection
public void MoveCurrentToPosition_Returns_False_For_Empty_Collection()
{
List<int> source = new List<int>();
CollectionView target = new CollectionView(source);
Assert.IsFalse(target.MoveCurrentToPosition(0));
Assert.IsNull(target.CurrentItem);
Assert.AreEqual(-1, target.CurrentPosition);
}
示例9: MoveCurrentToPosition
public void MoveCurrentToPosition ()
{
CollectionView c = new CollectionView (new object [] { 1, 2 });
Assert.IsTrue (c.MoveCurrentToPosition (1), "1");
Assert.AreEqual (c.CurrentItem, 2, "2");
Assert.AreEqual (c.CurrentPosition, 1, "3");
Assert.IsFalse (c.MoveCurrentToPosition (2), "4");
Assert.AreEqual (c.CurrentItem, null, "5");
Assert.AreEqual (c.CurrentPosition, 2, "6");
try {
c.MoveCurrentToPosition (3);
Assert.Fail ("7");
} catch (ArgumentOutOfRangeException ex) {
Assert.AreEqual (ex.ParamName, "position", "8");
}
Assert.AreEqual (c.CurrentItem, null, "9");
Assert.AreEqual (c.CurrentPosition, 2, "10");
c = new CollectionView (new object [] { 1, 2 });
try {
c.MoveCurrentToPosition (3);
Assert.Fail ("11");
} catch (ArgumentOutOfRangeException ex) {
Assert.AreEqual (ex.ParamName, "position", "12");
}
}