当前位置: 首页>>代码示例>>C#>>正文


C# PagedCollectionView.MoveCurrentToLast方法代码示例

本文整理汇总了C#中System.Windows.Data.PagedCollectionView.MoveCurrentToLast方法的典型用法代码示例。如果您正苦于以下问题:C# PagedCollectionView.MoveCurrentToLast方法的具体用法?C# PagedCollectionView.MoveCurrentToLast怎么用?C# PagedCollectionView.MoveCurrentToLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Data.PagedCollectionView的用法示例。


在下文中一共展示了PagedCollectionView.MoveCurrentToLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetItemsSourceAndChangePageSize

        public void SetItemsSourceAndChangePageSize()
        {
            // Create the ItemsSource
            List<string> strings = new List<string>() { "one", "two", "three", "four" };
            PagedCollectionView pagedCollectionView = new PagedCollectionView(strings);
            pagedCollectionView.MoveCurrentToLast();

            // Create the DataGrid
            bool isLoaded = false;
            DataGrid dataGrid = new DataGrid();
            dataGrid.Loaded += delegate { isLoaded = true; };
            dataGrid.ItemsSource = pagedCollectionView;
            TestPanel.Children.Add(dataGrid);
            this.EnqueueConditional(delegate { return isLoaded; });

            // Initially, the DG's selected item should be the last item
            Assert.AreEqual(4, dataGrid.SlotCount, "Incorrect SlotCount after adding and removing items");
            Assert.AreEqual(4, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after adding and removing items");
            Assert.AreEqual(3, dataGrid.SelectedIndex, "SelectedIndex was not updated when collection changed");
            Assert.AreEqual("four", dataGrid.SelectedItem, "SelectedItem was not updated when collection changed");

            // Changing the PageSize should cause the current and selected item to change
            pagedCollectionView.PageSize = 2;
            this.EnqueueYieldThread();
            this.EnqueueCallback(delegate
            {
                Assert.AreEqual(2, dataGrid.SlotCount, "Incorrect SlotCount after adding and removing items");
                Assert.AreEqual(2, dataGrid.VisibleSlotCount, "Incorrect VisibleSlotCount after adding and removing items");
                Assert.AreEqual(0, dataGrid.SelectedIndex, "SelectedIndex was not updated when collection changed");
                Assert.AreEqual("one", dataGrid.SelectedItem, "SelectedItem was not updated when collection changed");
            });
            this.EnqueueTestComplete();
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:33,代码来源:ItemsSource.cs


注:本文中的System.Windows.Data.PagedCollectionView.MoveCurrentToLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。