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 6148971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:22:29+00:00 2026-05-23T19:22:29+00:00

I am working on a project where I have implemented MVVM for WPF desktop

  • 0

I am working on a project where I have implemented MVVM for WPF desktop application. I have a situation where I wanted to make Datagrid editable just like old MS Access table list view. I am binding Datagrid’s ItemsSource to ObservableCollection Where Member implements INPC. Now I want to allow users to update member by clicking on any cell of the column, when they navigate to other row or Lost Focus the data should be validated and then saved to the DB.

How to capture such events in my ViewModel and how can I achieve this simple functionality?

  • 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-23T19:22:30+00:00Added an answer on May 23, 2026 at 7:22 pm

    You can trigger the “save” actions by binding the SelectedItem of the grid to a property on your viewmodel, and in the setter of the property you can save the previously selected item before replacing it with the newly selected item, in brief pseudo code it would look something like this:

    public MyDataObject SelectedItem
    {
        get { return _selectedItem; }
        set 
        {
            if (value != _selectedItem)
            {
                SaveMyItem(_selectedItem);
                _selectedItem = value;
                OnPropertyChanged("SelectedItem");
            }
        }
    }
    
    private MyDataObject _selectedItem;
    
    <DataGrid ItemsSource="{Binding MyCollection}" SelectedItem="{Binding SelectedItem, UpdateSourceTrigger=PropertyChanged}" ...etc... />
    

    Of course you may need to tailor this approach somewhat – if it takes a noticeable amount of time to save the modified item then you will want to do that on a background thread. If you specify the validation as part of the column bindings on the grid, the user will not be able to select and edit a new row until the data has correctly validated.

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

Sidebar

Related Questions

I am currently working on a project of mine which is a MSPaint-like WPF
Hy guys! I am currently working on a little WPF project using MVVM via
I have implemented Facebook Connect in my iPhone project and it is working great.
Working on a project at the moment and we have to implement soft deletion
I have project that I'm working on that is going to require a webserver.
I'm working on a project where I have 2 web services that need the
On a recent project I have been working on in C#/ASP.NET I have some
I'm working on a project were we have number (5 at the moment) of
I am working a project that does not have a trunk / branches /
One long term project I have is working through all the exercises of SICP.

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.