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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:54:22+00:00 2026-05-25T05:54:22+00:00

I am just starting with a WPF Browser application. I would like to handle

  • 0

I am just starting with a WPF Browser application.

I would like to handle the Before Close Event of the browser, so how would i handle that event?

  • 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-25T05:54:22+00:00Added an answer on May 25, 2026 at 5:54 am

    I found this solution.

    In the App.xaml.cs file:

     private void Application_Onexit(object sender, ExitEventArgs e)
    
            { 
    
              //write your code in here!
    
            }
    

    In the App.xaml file:

    <Application x:Class="(yourclasss)"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 Startup="Application_Startup"
                 Exit="Application_Onexit"
                 ShutdownMode="OnLastWindowClose"
                 StartupUri="startup.xaml">
    

    So basically the ShutdownMode property needs to be set in order to make it work.

    Then add a event in app.xaml.cs:

    public static event EventHandler UnloadPageWorkaround;
    
    public void Application_Onexit(object sender, ExitEventArgs e)
    {
        UnloadPageWorkaround.Invoke(null, null);
    }
    

    Then on the relevant page:

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
    
            WPFBrowser.App.UnloadPageWorkaround += new EventHandler(DoMySpecialPageCleanupStuff);
        }
    
        void DoMySpecialPageCleanupStuff(object sender, EventArgs e)
        {
            //do cleanup
        }       
    

    The only problem with this is, you can’t stop the application from exiting.

    Hope it helps.

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

Sidebar

Related Questions

Im just starting out with wpf (in blend 4) and i would like to
I am just starting with WPF and I have this ListBox that displays an
I'm just starting to use the composite application libraries for WPF. In my shell
So I'm just starting out with WPF, and I'm really annoyed by the fact
My company is just starting to look at using WPF for migrating all of
I'm just starting out with WPF and I'm trying to layout a UI. I
I'm just starting to work with Silverlight (no WPF experience either) and am having
I was on the process of starting a new WPF application with VS2010 beta
Is there any opensource library/WPF Control that can act as bitmap editor (e.g. just
Just starting to use Ruby on Rails to see what its like. I have

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.