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


C# DataGrid.ProcessDownKey方法代码示例

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


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

示例1: ItemsSource


//.........这里部分代码省略.........
                });
                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");
                    Assert.IsNull(control.CurrentColumn, "There should be no current cell if CollectionView.CurrentItem is null");

                    Assert.AreEqual(5, this._counter, "SelectionChanged should have been raised");
                    Assert.IsNotNull(this._selectionChangedEventArgs, "SelectionChanged should have been raised");
                    Assert.IsNotNull(this._selectionChangedEventArgs.AddedItems);
                    Assert.AreEqual(0, this._selectionChangedEventArgs.AddedItems.Count, "No items 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(pcv2[1], this._selectionChangedEventArgs.RemovedItems[0], "A single item should have been removed");

                    control.ProcessDownKey();
                });
                this.EnqueueYieldThread();

                this.EnqueueCallback(delegate
                {
                    Assert.AreEqual(pcv3[0], control.SelectedItem, "The first item should be selected after pressing the down key");
                    Assert.AreEqual(0, control.SelectedIndex, "The first item should be selected after pressing the down key");
                    Assert.AreEqual(0, control.CurrentColumnIndex, "The first cell should be current after pressing the down key");
                    Assert.AreEqual(control.Columns[0], control.CurrentColumn, "The first cell should be current after pressing the down key");

                    Assert.AreEqual(6, 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(pcv3[0], this._selectionChangedEventArgs.AddedItems[0], "A single item should have been added");
                    Assert.IsNotNull(this._selectionChangedEventArgs.RemovedItems);
                    Assert.AreEqual(0, this._selectionChangedEventArgs.RemovedItems.Count, "No items should have been removed");
                });
            }

            // Verify dependency property callback
            if (hasSideEffects)
            {
                MethodInfo methodInfo = typeof(DataGrid).GetMethod("OnItemsSourcePropertyChanged", BindingFlags.Static | BindingFlags.NonPublic);
                Assert.IsNotNull(methodInfo, "Expected DataGrid.ItemsSource to have static, non-public side-effect callback 'OnItemsSourcePropertyChanged'.");

                // 
            }
            else
            {
                MethodInfo methodInfo = typeof(DataGrid).GetMethod("OnItemsSourcePropertyChanged", BindingFlags.Static | BindingFlags.NonPublic);
                Assert.IsNull(methodInfo, "Expected DataGrid.ItemsSource NOT to have static side-effect callback 'OnItemsSourcePropertyChanged'.");
            }

            this.EnqueueTestComplete();
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:101,代码来源:ItemsSource.cs


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