public void PropertyGridViewAccessibleObject_Entry_IsOffscreen_ReturnsCorrectValue() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.Size = new Size(300, 500); propertyGrid.Location = new Point(0, 0); propertyGrid.CreateControl(); using ComboBox comboBox = new ComboBox(); propertyGrid.SelectedObject = comboBox; ControlAccessibleObject accessibleObject = (ControlAccessibleObject)propertyGrid.GridViewAccessibleObject; PropertyGridView propertyGridView = (PropertyGridView)accessibleObject.Owner; Rectangle gridViewRectangle = accessibleObject.Bounds; int ROWLABEL = 1; int ROWVALUE = 2; foreach (GridEntry category in propertyGrid.GetPropEntries()) { AccessibleObject categoryAccessibilityObject = category.AccessibilityObject; int row = propertyGridView.GetRowFromGridEntry(category); Rectangle rect = propertyGridView.GetRectangle(row, ROWVALUE | ROWLABEL); rect = propertyGridView.RectangleToScreen(rect); bool visible = rect.Height > 0 && ((rect.Y > gridViewRectangle.Y + 1 && rect.Y < gridViewRectangle.Bottom - 1) || (rect.Y <gridViewRectangle.Bottom - 1 && rect.Bottom> gridViewRectangle.Y + 1)); // +-1 are borders Assert.Equal(!visible, (bool)categoryAccessibilityObject.GetPropertyValue(UiaCore.UIA.IsOffscreenPropertyId)); foreach (GridEntry entry in category.Children) { AccessibleObject entryAccessibilityObject = entry.AccessibilityObject; row = propertyGridView.GetRowFromGridEntry(entry); rect = propertyGridView.GetRectangle(row, ROWVALUE | ROWLABEL); rect = propertyGridView.RectangleToScreen(rect); visible = rect.Height > 0 && ((rect.Y > gridViewRectangle.Y + 1 && rect.Y < gridViewRectangle.Bottom - 1) || (rect.Y <gridViewRectangle.Bottom - 1 && rect.Bottom> gridViewRectangle.Y + 1)); // +-1 are borders Assert.Equal(!visible, (bool)entryAccessibilityObject.GetPropertyValue(UiaCore.UIA.IsOffscreenPropertyId)); } } }