![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to close the app from anywhere in the app? How can an application be closed from a location other than the ShellWIndow? In this case, File->Exit's command handler is in a class derived from IApplicationView and it needs to close the application. How can this be done? -- Richard Lewis Haggard General: www.Haggard-And-Associates.com Please come visit here for a couple thousand good giggles!: www.haggard-and-associates.com/Humor/humor.htm |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: How to close the app from anywhere in the app? > How can an application be closed from a location other than the > ShellWIndow? In this case, File->Exit's command handler is in a class > derived from IApplicationView and it needs to close the application. How > can this be done? From Application.Run() documentation: "An application stops running when Shutdown is called;" Hence I suggest: Application.Current.Shutdown() > -- > Richard Lewis Haggard > General: www.Haggard-And-Associates.com > Please come visit here for a couple thousand good giggles!: > www.haggard-and-associates.com/Humor/humor.htm > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: How to close the app from anywhere in the app? Environment.Exit(0); seems to work. Application did not offer me the options of Current.Shutdown(); -- Richard Lewis Haggard General: www.Haggard-And-Associates.com Please come visit here for a couple thousand good giggles!: www.haggard-and-associates.com/Humor/humor.htm "Lloyd Dupont" <net.galador@ld> wrote in message news:e05NxxV2HHA.5796@TK2MSFTNGP05.phx.gbl... >> How can an application be closed from a location other than the >> ShellWIndow? In this case, File->Exit's command handler is in a class >> derived from IApplicationView and it needs to close the application. How >> can this be done? > > From Application.Run() documentation: > "An application stops running when Shutdown is called;" > > Hence I suggest: Application.Current.Shutdown() > >> -- >> Richard Lewis Haggard >> General: www.Haggard-And-Associates.com >> Please come visit here for a couple thousand good giggles!: >> www.haggard-and-associates.com/Humor/humor.htm >> >> > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: How to close the app from anywhere in the app? I just did Close(): public partial class MainWindow : System.Windows.Window { public MainWindow() { InitializeComponent(); } void OnExit (object sender, RoutedEventArgs e) { Close(); } } "Lloyd Dupont" <net.galador@ld> wrote in message news:e05NxxV2HHA.5796@TK2MSFTNGP05.phx.gbl... >> How can an application be closed from a location other than the >> ShellWIndow? In this case, File->Exit's command handler is in a class >> derived from IApplicationView and it needs to close the application. How >> can this be done? > > From Application.Run() documentation: > "An application stops running when Shutdown is called;" > > Hence I suggest: Application.Current.Shutdown() > >> -- >> Richard Lewis Haggard >> General: www.Haggard-And-Associates.com >> Please come visit here for a couple thousand good giggles!: >> www.haggard-and-associates.com/Humor/humor.htm >> >> > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: How to close the app from anywhere in the app? Indeed, this works fine from within the Window derived class. However, the question predicated that the close may be called from anywhere within the application, not just within the main window. I'd originally thought that there would be some easy way to get hold of the main window but was unable to find such functionality. In the end, I found a work around so the question is now mute. Thanks anyway. -- Richard Lewis Haggard General: www.Haggard-And-Associates.com Please come visit here for a couple thousand good giggles!: www.haggard-and-associates.com/Humor/humor.htm "StanB" <stan@community.nospam.com> wrote in message news:e%23yCMAo2HHA.1204@TK2MSFTNGP03.phx.gbl... >I just did Close(): > > public partial class MainWindow : System.Windows.Window > { > public MainWindow() > { > InitializeComponent(); > } > > void OnExit (object sender, RoutedEventArgs e) > { > Close(); > } > } > > "Lloyd Dupont" <net.galador@ld> wrote in message > news:e05NxxV2HHA.5796@TK2MSFTNGP05.phx.gbl... >>> How can an application be closed from a location other than the >>> ShellWIndow? In this case, File->Exit's command handler is in a class >>> derived from IApplicationView and it needs to close the application. How >>> can this be done? >> >> From Application.Run() documentation: >> "An application stops running when Shutdown is called;" >> >> Hence I suggest: Application.Current.Shutdown() >> >>> -- >>> Richard Lewis Haggard >>> General: www.Haggard-And-Associates.com >>> Please come visit here for a couple thousand good giggles!: >>> www.haggard-and-associates.com/Humor/humor.htm >>> >>> >> > > |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: How to close the app from anywhere in the app? "Richard Lewis Haggard" <HaggardAtWorldDotStdDotCom> wrote in message news:eUNWxL22HHA.5240@TK2MSFTNGP02.phx.gbl... > Environment.Exit(0); seems to work. Application did not offer me the > options of Current.Shutdown(); > -- Didn't it? Are you sure you are writting a "standart" WPF application? That is one with: public partial class App : System.Windows.Application Because, here are some snippets from System.Windows.Application documentation: public static Application Current { get; } public void Shutdown () Anyway, good that you found a method to do it. I'm just curious to know if we talked about the same thing.... |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| close with the X means close, not minimze to the system tray | Destin_FL | Live Mail | 3 | 07-27-2008 10:03 AM |
| Close Tabs Closes Everything! I don't want to Close Everything! | Robbia | Vista mail | 1 | 04-07-2008 11:42 AM |
| cannot close windows media player when i click the 'close' button | yulung | Vista music pictures video | 2 | 12-24-2007 04:37 PM |
| Close this program or search for the right topic and close this pr | Allan | Vista security | 0 | 07-18-2007 07:28 AM |
| It's getting close... | Travis King | Vista General | 14 | 05-22-2006 08:48 AM |