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


C# DataGrid.GetRowFromItem方法代码示例

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


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

示例1: DataGridCell_AutomationPeer

        public void DataGridCell_AutomationPeer()
        {
            List<Customer> boundList = CreateCustomerList(1);
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            isLoaded = false;
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);
            dataGrid.AutoGenerateColumns = true;
            dataGrid.ItemsSource = boundList;

            TestPanel.Children.Add(dataGrid);
            EnqueueConditional(delegate { return isLoaded; });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                DataGridCell cell = dataGrid.GetRowFromItem(boundList[0]).Cells[0];
                AutomationPeer peer = DataGridAutomationPeer.CreatePeerForElement(cell);
                Assert.IsNotNull(peer);
                Assert.AreEqual(cell.GetType().Name, peer.GetClassName(), "Incorrect ClassName value");
                Assert.AreEqual(AutomationControlType.Custom, peer.GetAutomationControlType(), "Incorrect ControlType value");
                Assert.AreEqual(true, peer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.AreEqual(true, peer.IsControlElement(), "Incorrect IsControlElement value");
                Assert.AreEqual(true, peer.IsKeyboardFocusable(), "Incorrect IsKeyBoardFocusable value");
                Assert.AreEqual(((TextBlock)cell.Content).Text, peer.GetName(), "Incorrect Name value");
                Assert.IsNotNull(peer.GetChildren(), "GetChildren should never return null");
            });

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

示例2: DataGridDetailsPresenter_AutomationPeer

        public void DataGridDetailsPresenter_AutomationPeer()
        {
            List<Customer> boundList = CreateCustomerList(15);
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            isLoaded = false;
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);
            dataGrid.AutoGenerateColumns = true;
            dataGrid.ItemsSource = boundList;
            dataGrid.SelectedItem = boundList[0];
            dataGrid.RowDetailsTemplate = (DataTemplate)XamlReader.Load(@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" ><TextBlock Text=""Test"" /></DataTemplate>");

            TestPanel.Children.Add(dataGrid);
            EnqueueConditional(delegate { return isLoaded; });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                DataGridDetailsPresenter details = dataGrid.GetRowFromItem(boundList[0]).TestHook.DetailsPresenter;
                AutomationPeer peer = DataGridAutomationPeer.CreatePeerForElement(details);
                Assert.IsNotNull(peer);
                Assert.AreEqual(typeof(DataGridDetailsPresenter).Name, peer.GetClassName(), "Incorrect ClassName value");
                Assert.AreEqual(AutomationControlType.Custom, peer.GetAutomationControlType(), "Incorrect ControlType value");
                Assert.AreEqual(false, peer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.AreEqual(true, peer.IsControlElement(), "Incorrect IsControlElement value");
                Assert.AreEqual(false, peer.IsKeyboardFocusable(), "Incorrect IsKeyBoardFocusable value");
                Assert.IsNotNull(peer.GetChildren(), "GetChildren should never return null");
            });

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

示例3: DataGridItem_ISelectionItemProvider

        public void DataGridItem_ISelectionItemProvider()
        {
            List<Customer> boundList = CreateCustomerList(5);
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            isLoaded = false;
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);
            dataGrid.AutoGenerateColumns = true;
            dataGrid.ItemsSource = boundList;
            dataGrid.ColumnWidth = new DataGridLength(100.0);

            TestPanel.Children.Add(dataGrid);
            EnqueueConditional(delegate { return isLoaded; });
            this.EnqueueYieldThread();

            List<DataGridRow> rows = new List<DataGridRow>();
            AutomationPeer peer;
            List<ISelectionItemProvider> selectionItems = new List<ISelectionItemProvider>();

            EnqueueCallback(delegate
            {
                for (int i = 0; i < boundList.Count; i++)
                {
                    rows.Add(dataGrid.GetRowFromItem(boundList[i]));
                    peer = new DataGridItemAutomationPeer(boundList[i], dataGrid);
                    Assert.IsNotNull(peer);
                    selectionItems.Add(peer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider);
                    Assert.IsNotNull(selectionItems[i]);
                    selectionItems[i].AddToSelection();
                }
            });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                foreach (DataGridRow row in rows)
                {
                    Assert.IsTrue(row.IsSelected);
                }

                foreach (ISelectionItemProvider select in selectionItems)
                {
                    select.RemoveFromSelection();
                }
            });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                foreach (DataGridRow row in rows)
                {
                    Assert.IsFalse(row.IsSelected);
                }

                selectionItems[0].Select();
                selectionItems[3].Select();
                selectionItems[3].Select();
            });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                Assert.IsFalse(rows[0].IsSelected);
                Assert.IsTrue(rows[3].IsSelected);

                dataGrid.SelectionMode = DataGridSelectionMode.Single;
                selectionItems[4].AddToSelection();
                // 






            });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                Assert.IsFalse(rows[2].IsSelected);
                Assert.IsTrue(rows[4].IsSelected);
            });

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


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