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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:48:07+00:00 2026-06-10T12:48:07+00:00

I have an application build with the MVVM pattern from Josh Smith ( http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

  • 0

I have an application build with the MVVM pattern from Josh Smith (http://msdn.microsoft.com/en-us/magazine/dd419663.aspx).

When I have several workspaces opened in my app, I want to catch the event of switching workspaces/tabs so I can save the content of the current workspace first. I have looked throught WorkspaceViewModel and ViewModelBase, but I don’t know how to add that EventHandler.

  • 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-06-10T12:48:09+00:00Added an answer on June 10, 2026 at 12:48 pm

    I have found a solution in another post, I just had to tweak it a little bit : What is the proper way to handle multiple datagrids in a tab control so that cells leave edit mode when the tabs are changed?

    Basically I have added an EventHandler on PreviewMouseDown of my TabControl generating the different Workspaces.

    private void TabControl_PreviewMouseDown(object sender, MouseButtonEventArgs e) {
            MainWindow_VM dc = (MainWindow_VM)this.DataContext;
    
            if (IsUnderTabHeader(e.OriginalSource as DependencyObject))
                //Do what need to be done before switching workspace
                // in my case, switch the focus to a dummy control so the objectContext would save everything, even the currently focused textbox
    
        }
    
    private bool IsUnderTabHeader(DependencyObject control) 
        {
            if (control is TabItem)
            {
                return true;
            }
            DependencyObject parent = VisualTreeHelper.GetParent(control); 
            if (parent == null)         
                return false; 
    
            return IsUnderTabHeader(parent); 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from this article http://marakana.com/forums/android/examples/49.html i have seen that the application build with help of
I' using the MVVM pattern to build an application. In this application I have
I have always admired the way Josh Smith has built his sample application .
I am trying to build a WPF application using the MVVM pattern. It would
I want to build a basic wpf/mvvm application which gets the data from a
I have started to build a WPF application in MVVM architecture (using Prism infrastructure).
I have a WPF application which is built on the MVVM design pattern. I
I have a WPF Application using MVVM pattern. I have a Window in my
I have an application build in C# for reading and saving SMS and MMS,
I have a flex application build with actionscript 3 on flex builder with unit

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.