Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

WPF - Closing Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dale Williams - 14 Mar 2008 15:04 GMT
Everyone:

When working with winform applications, you could check the reason for
closing the window.  As in this example:
       private void MainForm_FormClosing(object sender,
FormClosingEventArgs e)
       {
           if (e.CloseReason == CloseReason.UserClosing)
           {
               if (CloseApplication())
                   Application.Exit();

               else
                   e.Cancel = true;

           }
       }

Now, e doesn't return a closereason.  Is there anyway to check why the
window is closing?

Thanks,
Dale Williams
Willy Denoyette [MVP] - 15 Mar 2008 10:36 GMT
> Everyone:
>
[quoted text clipped - 19 lines]
> Thanks,
> Dale Williams

Application life cycle is separated from the Window life cycle in WPF.
Application events must be handled by the Application event handlers.
Following snippet sample uses XAML to register the SessionEnding
handler.....

// XAML
<Application....
....
SessionEnding="App_SessionEnding">

// Code
public partial class App : Application
{
       void App_SessionEnding(object sender, SessionEndingCancelEventArgs
e)
       {
           if(e.ReasonSessionEnding =
               ...
       }

Consult MSDN for more info...

Willy.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.