How to quit the entire Microsoft Lightswitch application?

In this example I will demonstrate how to quit the entire Microsoft Lightswitch application and at the same time provide you an example on how to use the built-in MessageBox class.  The two activities are crucial to my application life cycle.  So here is it:

Put the code below to a method, for example, a Quit method:

            If Me.ShowMessageBox(“Are you sure you want to quit?”, “Quit”, MessageBoxOption.YesNo) = System.Windows.MessageBoxResult.Yes Then
                                            If System.Windows.Application.Current.IsRunningOutOfBrowser Then
                                            End If
                                        End Sub)
            End If

Thats it. If you find an error upon pasting the code above just include the reference.


Software developer living in the Philippines.

Posted in Lightswitch
3 comments on “How to quit the entire Microsoft Lightswitch application?
  1. JR says:

    Hi, thank you for sharing this.. I’m new to LS and this post helped me with my concern. although, I have another concern and I hope you could help me too. In the attached screenshot, you have a modified login screen. I’m particularly interested on how you incorporated the “Branch” field with a dropdown list. Can you show me how you were able to accomplish this.. Thanks in advance.

    • hgminerva says:

      I did not use the built-in security of lightswitch, you can only customize it through the shell, instead I use a simple home screen with a user and password field. Then record the current user in the application class that will be consumed by all screen on created event.

  2. C# Code:

    partial void _Closing(ref bool cancel)
    if (this.ShowMessageBox(“Are you sure you want to quit?”, “Quit”, MessageBoxOption.YesNo) == System.Windows.MessageBoxResult.Yes)
    Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() => {
    if (System.Windows.Application.Current.IsRunningOutOfBrowser) {
    } else {

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn


Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: