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


C# DataGrid.GetType方法代码示例

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


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

示例1: DataGrid_AutomationPeer

        public void DataGrid_AutomationPeer()
        {
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            isLoaded = false;
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);

            DataGridAutomationPeer peer = ((DataGridAutomationPeer)DataGridAutomationPeer.CreatePeerForElement(dataGrid));
            Assert.IsNotNull(peer);

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

            EnqueueCallback(delegate
            {
                Assert.AreEqual(dataGrid.Height, peer.GetBoundingRectangle().Height, "Incorrect BoundingRectangle.Height value");
                Assert.AreEqual(dataGrid.Width, peer.GetBoundingRectangle().Width, "Incorrect BoundingRectangle.Width value");
                Assert.AreEqual(dataGrid.GetType().Name, peer.GetClassName(), "Incorrect ClassName value");
                Assert.AreEqual(Automation.Peers.AutomationControlType.DataGrid, 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.IsNotNull(peer.GetPattern(PatternInterface.Grid), "Incorrect GetPattern result for PatternInterface.Grid");
                Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "Incorrect GetPattern result for PatternInterface.Scroll");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Selection), "Incorrect GetPattern result for PatternInterface.Selection");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Table), "Incorrect GetPattern result for PatternInterface.Table");
                Assert.IsNotNull(peer.GetChildren(), "GetChildren should never return null");
            });

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

示例2: DataGrid_AutomationPeer

        public void DataGrid_AutomationPeer()
        {
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            isLoaded = false;
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);

            DataGridAutomationPeer peer = ((DataGridAutomationPeer)DataGridAutomationPeer.CreatePeerForElement(dataGrid));
            Assert.IsNotNull(peer);

            TextBlock label = new TextBlock();
            label.Text = "labelText";

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

            EnqueueCallback(delegate
            {
                Assert.AreEqual(dataGrid.Height, peer.GetBoundingRectangle().Height, "Incorrect BoundingRectangle.Height value");
                Assert.AreEqual(dataGrid.Width, peer.GetBoundingRectangle().Width, "Incorrect BoundingRectangle.Width value");
                Assert.AreEqual(dataGrid.GetType().Name, peer.GetClassName(), "Incorrect ClassName value");
                Assert.AreEqual(AutomationControlType.DataGrid, 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");

                // The NameProperty should get its value in the order: base(Label), DataGrid.Name, then DataGrid class name
                Assert.AreEqual("DataGrid", peer.GetName(), "Incorrect default Name value");
                dataGrid.Name = "dataGridTest";
                Assert.AreEqual("dataGridTest", peer.GetName(), "Incorrect Name value after setting DataGrid.Name");
                AutomationProperties.SetLabeledBy(dataGrid, label);
                Assert.AreEqual(label.Text, peer.GetName(), "Incorrect Name value after setting LabeledBy property");

                Assert.IsNotNull(peer.GetPattern(PatternInterface.Grid), "Incorrect GetPattern result for PatternInterface.Grid");
                Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "Incorrect GetPattern result for PatternInterface.Scroll");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Selection), "Incorrect GetPattern result for PatternInterface.Selection");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Table), "Incorrect GetPattern result for PatternInterface.Table");
                
                bool columnHeadersPresenterFound = false;
                bool rowsPresenterFound = false;
                bool validationSummaryFound = false;
                List<AutomationPeer> children = peer.GetChildren();
                Assert.IsNotNull(children, "GetChildren should never return null");
                Assert.AreEqual(3, children.Count, "Incorrect number of children");
                foreach (AutomationPeer child in children)
                {
                    if (child is DataGridColumnHeadersPresenterAutomationPeer)
                    {
                        columnHeadersPresenterFound = true;
                    }
                    else if (child is DataGridRowsPresenterAutomationPeer)
                    {
                        rowsPresenterFound = true;
                    }
                    else if (child is ValidationSummaryAutomationPeer)
                    {
                        validationSummaryFound = true;
                    }
                }
                Assert.IsTrue(columnHeadersPresenterFound, "ColumnHeadersPresenter was not found in children");
                Assert.IsTrue(rowsPresenterFound, "RowsPresenter was not found in children");
                Assert.IsTrue(validationSummaryFound, "ValidationSummary was not found in children");
            });

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


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