本文整理汇总了C#中System.Windows.Data.PagedCollectionView.MoveCurrentToPosition方法的典型用法代码示例。如果您正苦于以下问题:C# PagedCollectionView.MoveCurrentToPosition方法的具体用法?C# PagedCollectionView.MoveCurrentToPosition怎么用?C# PagedCollectionView.MoveCurrentToPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Data.PagedCollectionView
的用法示例。
在下文中一共展示了PagedCollectionView.MoveCurrentToPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureCurrentIndexSyncedAfterCollectionViewMovesToAfterLast
public void EnsureCurrentIndexSyncedAfterCollectionViewMovesToAfterLast()
{
DataFormApp_Standard dataFormApp = new DataFormApp_Standard();
PagedCollectionView pcv = new PagedCollectionView(DataClassList.GetDataClassList(2, ListOperations.All));
dataFormApp.dataForm.ItemsSource = pcv;
this.EnqueueCallback(() =>
{
this.DataFormAppBase = dataFormApp;
});
this.AddToPanelAndWaitForLoad();
this.EnqueueCallback(() =>
{
Assert.AreEqual(0, pcv.CurrentPosition);
Assert.AreEqual(pcv[0], dataFormApp.dataForm.CurrentItem);
this.ExpectCurrentItemChange();
pcv.MoveCurrentToPosition(2);
});
this.WaitForCurrentItemChange();
this.EnqueueCallback(() =>
{
Assert.AreEqual(2, pcv.CurrentPosition);
Assert.AreEqual(2, dataFormApp.dataForm.CurrentIndex);
Assert.IsNull(dataFormApp.dataForm.CurrentItem);
this.ExpectCurrentItemChange();
pcv.MoveCurrentToPosition(0);
});
this.WaitForCurrentItemChange();
this.EnqueueCallback(() =>
{
this.ExpectCurrentItemChange();
dataFormApp.dataForm.CurrentIndex = 2;
});
this.WaitForCurrentItemChange();
this.EnqueueCallback(() =>
{
Assert.AreEqual(2, pcv.CurrentPosition);
Assert.AreEqual(2, dataFormApp.dataForm.CurrentIndex);
Assert.IsNull(dataFormApp.dataForm.CurrentItem);
});
this.EnqueueTestComplete();
}
示例2: MoveCurrencyToNullWhenAppending
public void MoveCurrencyToNullWhenAppending()
{
DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
List<DataClassWithValidation> dataClassList =
new List<DataClassWithValidation>()
{
new DataClassWithValidation()
{
StringProperty = "string 1"
}
};
PagedCollectionView pcv = new PagedCollectionView(dataClassList);
this.EnqueueCallback(() =>
{
dataFormApp.dataForm.ItemsSource = pcv;
this.DataFormAppBase = dataFormApp;
});
this.AddToPanelAndWaitForLoad();
this.EnqueueCallback(() =>
{
this.ExpectCurrentItemChange();
dataFormApp.dataForm.AddNewItem();
});
this.WaitForCurrentItemChange();
this.EnqueueCallback(() =>
{
Assert.AreEqual(2, pcv.Count);
this.ExpectCurrentItemChange();
pcv.MoveCurrentToPosition(-1);
});
this.WaitForCurrentItemChange();
this.EnqueueCallback(() =>
{
Assert.AreEqual(1, pcv.Count);
});
this.EnqueueTestComplete();
}
示例3: EnsureCollectionViewAtBeforeFirstIsMovedToFirst
public void EnsureCollectionViewAtBeforeFirstIsMovedToFirst()
{
DataFormApp_Standard dataFormApp = new DataFormApp_Standard();
PagedCollectionView cv = new PagedCollectionView(DataClassList.GetDataClassList(2, ListOperations.All));
cv.MoveCurrentToPosition(-1);
dataFormApp.dataForm.ItemsSource = cv;
this.EnqueueCallback(() =>
{
this.DataFormAppBase = dataFormApp;
});
this.AddToPanelAndWaitForLoad();
this.EnqueueCallback(() =>
{
Assert.AreEqual(0, cv.CurrentPosition);
});
this.EnqueueTestComplete();
}
示例4: ItemsSource
//.........这里部分代码省略.........
Assert.AreEqual(0, control.CurrentColumnIndex, "The first cell should be current by default");
Assert.AreEqual(control.Columns[0], control.CurrentColumn, "The first cell should be current by default");
Assert.AreEqual(2, this._counter, "SelectionChanged should have been raised");
Assert.IsNotNull(this._selectionChangedEventArgs, "SelectionChanged should have been raised");
Assert.IsNotNull(this._selectionChangedEventArgs.AddedItems);
Assert.AreEqual(1, this._selectionChangedEventArgs.AddedItems.Count, "A single item should have been added");
Assert.AreEqual(data3[3], this._selectionChangedEventArgs.AddedItems[0], "A single item should have been added");
Assert.IsNotNull(this._selectionChangedEventArgs.RemovedItems);
Assert.AreEqual(1, this._selectionChangedEventArgs.RemovedItems.Count, "A single item should have been removed");
Assert.AreEqual(data2[1], this._selectionChangedEventArgs.RemovedItems[0], "A single item should have been removed");
control.ItemsSource = pcv1;
});
this.EnqueueYieldThread();
this.EnqueueCallback(delegate
{
Assert.AreEqual(pcv1, control.ItemsSource);
Assert.AreEqual(pcv1[0], control.SelectedItem, "First item was not selected when setting ItemsSource to an ICollectionView");
Assert.AreEqual(0, control.SelectedIndex, "First item was not selected when setting ItemsSource to an ICollectionView");
Assert.AreEqual(0, control.CurrentColumnIndex, "The first cell should be current by default");
Assert.AreEqual(control.Columns[0], control.CurrentColumn, "The first cell should be current by default");
Assert.AreEqual(3, this._counter, "SelectionChanged should have been raised");
Assert.IsNotNull(this._selectionChangedEventArgs, "SelectionChanged should have been raised");
Assert.IsNotNull(this._selectionChangedEventArgs.AddedItems);
Assert.AreEqual(1, this._selectionChangedEventArgs.AddedItems.Count, "A single item should have been added");
Assert.AreEqual(pcv1[0], this._selectionChangedEventArgs.AddedItems[0], "A single item should have been added");
Assert.IsNotNull(this._selectionChangedEventArgs.RemovedItems);
Assert.AreEqual(1, this._selectionChangedEventArgs.RemovedItems.Count, "A single item should have been removed");
Assert.AreEqual(data3[3], this._selectionChangedEventArgs.RemovedItems[0], "A single item should have been removed");
pcv2.MoveCurrentToPosition(1);
control.ItemsSource = pcv2;
});
this.EnqueueYieldThread();
this.EnqueueCallback(delegate
{
Assert.AreEqual(pcv2, control.ItemsSource);
Assert.AreEqual(pcv2[1], control.SelectedItem, "CollectionView.CurrentItem was not selected by default");
Assert.AreEqual(1, control.SelectedIndex, "CollectionView.CurrentItem was not selected by default");
Assert.AreEqual(0, control.CurrentColumnIndex, "The first cell should be current by default");
Assert.AreEqual(control.Columns[0], control.CurrentColumn, "The first cell should be current by default");
Assert.AreEqual(4, this._counter, "SelectionChanged should have been raised");
Assert.IsNotNull(this._selectionChangedEventArgs, "SelectionChanged should have been raised");
Assert.IsNotNull(this._selectionChangedEventArgs.AddedItems);
Assert.AreEqual(1, this._selectionChangedEventArgs.AddedItems.Count, "A single item should have been added");
Assert.AreEqual(pcv2[1], this._selectionChangedEventArgs.AddedItems[0], "A single item should have been added");
Assert.IsNotNull(this._selectionChangedEventArgs.RemovedItems);
Assert.AreEqual(1, this._selectionChangedEventArgs.RemovedItems.Count, "A single item should have been removed");
Assert.AreEqual(pcv1[0], this._selectionChangedEventArgs.RemovedItems[0], "A single item should have been removed");
pcv3.MoveCurrentToPosition(-1);
control.ItemsSource = pcv3;
});
this.EnqueueYieldThread();
this.EnqueueCallback(delegate
{
Assert.AreEqual(pcv3, control.ItemsSource);
Assert.IsNull(control.SelectedItem, "No items should be selected if CollectionView.CurrentItem is null");
Assert.AreEqual(-1, control.SelectedIndex, "No items should be selected if CollectionView.CurrentItem is null");
Assert.AreEqual(-1, control.CurrentColumnIndex, "There should be no current cell if CollectionView.CurrentItem is null");