本文整理汇总了C#中System.Windows.Data.PagedCollectionView.MoveToPage方法的典型用法代码示例。如果您正苦于以下问题:C# PagedCollectionView.MoveToPage方法的具体用法?C# PagedCollectionView.MoveToPage怎么用?C# PagedCollectionView.MoveToPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Data.PagedCollectionView
的用法示例。
在下文中一共展示了PagedCollectionView.MoveToPage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPropertyChangedTest
public void OnPropertyChangedTest()
{
List<EditableTestClass> efbList = new List<EditableTestClass>();
ObservableCollection<TestClass> fbCollection = new ObservableCollection<TestClass>();
PagedCollectionView pcv1 = new PagedCollectionView(efbList);
PagedCollectionView pcv2 = new PagedCollectionView(fbCollection);
pcv1.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.PagedCollectionViewPropertyChanged);
pcv2.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.PagedCollectionViewPropertyChanged);
this._expectedPropertyNames.Clear();
this._expectedPropertyNames.Add("Count");
this._expectedPropertyNames.Add("IsEmpty");
this._expectedPropertyNames.Add("IsCurrentAfterLast");
this.AssertExpectedEvent(delegate { fbCollection.Add(new TestClass()); });
this.CheckExpectedPropertyNamesFound();
this._expectedPropertyNames.Clear();
this._expectedPropertyNames.Add("IsCurrentBeforeFirst");
this._expectedPropertyNames.Add("CurrentPosition");
this._expectedPropertyNames.Add("CurrentItem");
this.AssertExpectedEvent(delegate { pcv2.MoveCurrentToFirst(); });
this.CheckExpectedPropertyNamesFound();
this._expectedPropertyNames.Clear();
this._expectedPropertyNames.Add("SortDescriptions");
this.AssertExpectedEvent(delegate { pcv1.SortDescriptions.Add(new System.ComponentModel.SortDescription("IntProperty", System.ComponentModel.ListSortDirection.Ascending)); });
this.CheckExpectedPropertyNamesFound();
this._expectedPropertyNames.Clear();
this._expectedPropertyNames.Add("Culture");
this.AssertExpectedEvent(delegate { pcv1.Culture = CultureInfo.InvariantCulture; });
this.CheckExpectedPropertyNamesFound();
this._expectedPropertyNames.Clear();
this._expectedPropertyNames.Add("Filter");
this.AssertExpectedEvent(delegate { pcv2.Filter = new Predicate<object>(this.FilterNegativeNumbers); });
this.CheckExpectedPropertyNamesFound();
// Attempt to move to Page 0 should fail while PageSize is still 0.
Assert.AreEqual(0, pcv1.PageSize);
Assert.IsFalse(pcv1.MoveToPage(0));
this._expectedPropertyNames.Clear();
this._expectedPropertyNames.Add("PageSize");
this.AssertExpectedEvent(delegate { pcv1.PageSize = 10; });
this.CheckExpectedPropertyNamesFound();
pcv1.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(this.PagedCollectionViewPropertyChanged);
pcv2.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(this.PagedCollectionViewPropertyChanged);
}
示例2: MoveToPageZeroWithNoItemsTest
public void MoveToPageZeroWithNoItemsTest()
{
List<int> intList = new List<int>();
PagedCollectionView pcv = new PagedCollectionView(intList);
pcv.PageSize = 5;
pcv.MoveToPage(0);
Assert.AreEqual(0, pcv.Count);
Assert.AreEqual(0, pcv.PageIndex);
}
示例3: CountTestWithNoItems
public void CountTestWithNoItems()
{
List<int> intList = new List<int>();
PagedCollectionView pcv = new PagedCollectionView(intList);
Assert.AreEqual(0, pcv.Count);
// update the PageSize and verify that we still have a Count of 0.
pcv.PageSize = 10;
Assert.AreEqual(0, pcv.Count);
// update the PageSize during a DeferRefresh and verify that we still have a Count of 0.
pcv.PageSize = 0;
using (pcv.DeferRefresh())
{
pcv.PageSize = 10;
pcv.MoveToPage(1);
}
Assert.AreEqual(0, pcv.Count);
// now try those same tests above with grouping
pcv.GroupDescriptions.Add(new PropertyGroupDescription(""));
pcv.PageSize = 0;
Assert.AreEqual(0, pcv.Count);
// update the PageSize and verify that we still have a Count of 0.
pcv.PageSize = 10;
Assert.AreEqual(0, pcv.Count);
// update the PageSize during a DeferRefresh and verify that we still have a Count of 0.
pcv.PageSize = 0;
using(pcv.DeferRefresh())
{
pcv.PageSize = 5;
}
Assert.AreEqual(0, pcv.Count);
}
示例4: GroupingInListBoxTest
public void GroupingInListBoxTest()
{
ObservableCollection<TestClass> collection = new ObservableCollection<TestClass>()
{
new TestClass { IntProperty = 1, StringProperty = "A" },
new TestClass { IntProperty = 2, StringProperty = "B" },
new TestClass { IntProperty = 3, StringProperty = "A" },
new TestClass { IntProperty = 4, StringProperty = "B" }
};
PagedCollectionView cv = new PagedCollectionView(collection);
ListBox lb = new ListBox();
lb.ItemsSource = cv;
this.CreateAsyncTask(
lb,
delegate
{
Assert.AreEqual(4, lb.Items.Count);
cv.GroupDescriptions.Add(new PropertyGroupDescription("StringProperty"));
Assert.AreEqual(4, lb.Items.Count);
Assert.AreEqual("A", (lb.Items[0] as TestClass).StringProperty);
Assert.AreEqual("A", (lb.Items[1] as TestClass).StringProperty);
Assert.AreEqual("B", (lb.Items[2] as TestClass).StringProperty);
Assert.AreEqual("B", (lb.Items[3] as TestClass).StringProperty);
cv.PageSize = 3;
cv.MoveToPage(1);
Assert.AreEqual(1, lb.Items.Count);
Assert.AreEqual("B", (lb.Items[0] as TestClass).StringProperty);
TestClass newItem = cv.AddNew() as TestClass;
newItem.StringProperty = "A";
newItem.IntProperty = 5;
// ---------------------
// |Page | 0 | 1 | 2 |
// ---------------------
// | 0 | A | A | B |
// | 1 | B |-A- | | <---- Current Page
Assert.AreEqual("B", (lb.Items[0] as TestClass).StringProperty);
Assert.AreEqual("A", (lb.Items[1] as TestClass).StringProperty);
cv.CommitNew();
// ---------------------
// |Page | 0 | 1 | 2 |
// ---------------------
// | 0 | A | A |-A- |
// | 1 | B | B | | <---- Current Page
Assert.AreEqual("B", (lb.Items[0] as TestClass).StringProperty);
Assert.AreEqual("B", (lb.Items[1] as TestClass).StringProperty);
cv.MoveToFirstPage();
Assert.AreEqual("A", (lb.Items[0] as TestClass).StringProperty);
Assert.AreEqual("A", (lb.Items[1] as TestClass).StringProperty);
Assert.AreEqual("A", (lb.Items[2] as TestClass).StringProperty);
});
EnqueueTestComplete();
}
示例5: CannotMoveToPageTest
public void CannotMoveToPageTest()
{
List<TestClass> intList = new List<TestClass>();
PagedCollectionView pcv = new PagedCollectionView(intList);
Assert.AreEqual(0, pcv.PageSize);
// if the PageSize is 0, you cannot move to page 0
Assert.IsFalse(pcv.MoveToPage(0));
// setting the PageSize to a positive number causes a
// move to page 0.
pcv.PageSize = 1;
Assert.AreEqual(0, pcv.PageIndex);
}