Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 929113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:06:58+00:00 2026-05-15T20:06:58+00:00

Note: This is no longer an issue, the .NET 4 built-in DataGrid solves this

  • 0

Note: This is no longer an issue, the .NET 4 built-in DataGrid solves this problem


I have a WPF app which is using a DataGrid; I’m using the WPF ui automation API to write some automated tests for it.
The DataGrid is the WPFToolkit one, I’m using the .NET 3.5SP1 with VS2008, and, the datagrid has multi-select enabled.

Where I’m at is that from my test can find the datagrid, and I can find individual cells within the grid using the GridPattern.GetItem method, and select them by setting SelectionItemPattern.Select. Method

The code looks somewhat like this:

AutomationElement mainGrid = // find the grid in the window
var columnCount = (int)mainGrid.GetCurrentPropertyValue(GridPattern.ColumnCountProperty);
var mainGridPattern = (GridPattern)mainGrid.GetCurrentPattern(GridPattern.Pattern);

var rowToSelect = 2;

// select just the first cell
var item = mainGridPattern.GetItem(rowToSelect, 0);
var itemPattern = (SelectionItemPattern)item.GetCurrentPattern(SelectionItemPattern.Pattern);
itemPattern.Select();

This seems to work, but it only selects the first individual cell, not the entire table row (which has 10 columns) but I can’t work out how to deselect an item. The only thing I can find that looks like it might work is to call SelectionItemPattern.AddToSelection() on the itemPattern, or the corresponding RemoveFromSelection but when I do either of these, the following exception is raised:

=> Cannot change cell selection when the SelectionUnit is FullRow.
   at MS.Internal.Automation.ElementUtil.Invoke(AutomationPeer peer, DispatcherOperationCallback work, Object arg)
   at MS.Internal.Automation.SelectionItemProviderWrapper.AddToSelection()

The underlying root issue appears to be that (as far as I can see) the WPF UI automation API has no concept of a grid Row, only cells. This seems somewhat problematic – Is this right?

Sidenote: I had previously been using the White UI automation framework – this doesn’t use UI automation to select grid rows, instead it moves the mouse to the row location and clicks it – which caused random failures of our tests – is this why they’re using the mouse to do the selection though?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:06:59+00:00Added an answer on May 15, 2026 at 8:06 pm

    This now seems to have been fixed in .NET 4. Rows are now exposed as real objects that support the SelectionItemPattern, so you can now select/deselect a row. Hooray

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By "Newdata is list of x columns", I imagine you… May 17, 2026 at 6:12 am
  • Editorial Team
    Editorial Team added an answer You can have as much customisation as you like in… May 17, 2026 at 6:12 am
  • Editorial Team
    Editorial Team added an answer You'll find that file at /js/prototype/validation.js note this is under… May 17, 2026 at 6:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

(Note: This is for MySQL's SQL, not SQL Server.) I have a database column
Note: this is a different problem to https - it's related to privacy security
(NOTE: This question is not about escaping queries, it's about escaping results) I'm using
Note: This is the opposite direction to most similar questions! I have an iPhone
Let's say I have a simple stored procedure that looks like this (note: this
Note that this function does not have a { and } body. Just a
I've built an ASP.net web application which allows the users to view and make
I have a Console App created in VS 2010 targeting .NET 4.0. According to
Note: This was posted when I was starting out C#. With 2014 knowledge, I
Note This is not a REBOL-specific question. You can answer it in any language.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.