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

  • SEARCH
  • Home
  • 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 7574827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:31:54+00:00 2026-05-30T16:31:54+00:00

.Net 4 WPF DataGrid MVVM User clicks add button which triggers command on viewmodel.

  • 0

.Net 4 WPF DataGrid MVVM

User clicks add button which triggers command on viewmodel. In the viewmodel command execute, I add a new object to the viewcollection of the viewmodel that the grid is bound to. The new row does appear in my grid. However, I also want to send the focus to the first editable cell in that new row.

I even “cheated” mvvm, added an event on my viewmodel that the view listens to, to know when to focus the new row.

I’ve searched but no luck. I was hopeful when I came across this:

Datagrid Set focus on newly added row

which leads to

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/63974f4f-d9ee-45af-8499-42f29cbc22ae

But the problem that others have reported and no one has answered is how to deal with the virtualizing behaviour of the grid. The newly added row has not yet been created. So that GetCells call fails frequently. And if ScrollIntoView is required, then it’s that much more likely to fail.

I’ve hooked a ton of events including LoadingRow and RequestBringIntoView with no luck. Depending on which event I hook, I have managed to be able to get a reference to the cell. But then I get an error “Cannot call StartAt when content generation is in progress”. But I checked the status of the ItemContainerGenerator and it was ContainersGenerated when I made the call to the cell’s BeginEdit.

  • 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-30T16:31:55+00:00Added an answer on May 30, 2026 at 4:31 pm

    Here is one way to set focus to a particular cell programmatically:

    DataGridCell cell = GetCell(rowIndex, colIndex);
    cell.Focus;
    

    Please see the following article for more information on GetCell().

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

Sidebar

Related Questions

I'm new to WPF and I'm finding that the WPF .Net 4.0 Datagrid doesn't
Details VS-2008 Professional SP1 Version .net 3.5 Language:C# I have a WPF Datagrid which
I'm using buildin WPF DataGrid in .net 4. I can set the background of
I have quastion about DataGrid in WPF .NET 4. Here is XAML code with
I am currently using a WPF datagrid which needs to be able to load
I have a wpf window which is used to add as well as edit
I have .NET WPF application and one of requirement is that user may select
I have a wpf datagrid (.NET 4.0) that contains raw data from a database,
I have a performance issue with the WPF DataGrid (.net 4.0) first, some details:
I am quite new to WPF and XAML but my background is of ASP.NET

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.