Articles → LIGHT SWITCH 2011 → Screen lost focus event in lightswitch 2011

Screen lost focus event in lightswitch 2011




















Software requirement











Prerequisite knowledge













Steps of execution













Create a new project





Click to Enlarge


Add 2 screens





Click to Enlarge


Add code for screen’s lost focus




using Microsoft.VisualStudio.ExtensibilityHosting;
using Microsoft.LightSwitch.Presentation.Extensions;
using Microsoft.LightSwitch.Sdk.Proxy;

namespace LightSwitchApplication
{
    public partial class Screen_one
    {
        partial void Screen_one_Activated()
        {
            IServiceProxy proxy = VsExportProviderService.GetExportedValue<IServiceProxy>();
            VsExportProviderService.GetExportedValue<IServiceProxy>().ActiveScreensViewModel.PropertyChanged += ActiveScreensViewModel_PropertyChanged;
        }

        void ActiveScreensViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            this.Details.Dispatcher.BeginInvoke(() =>
            {
                VsExportProviderService.GetExportedValue<IServiceProxy>().ActiveScreensViewModel.PropertyChanged -= ActiveScreensViewModel_PropertyChanged;
                this.ShowMessageBox("Screen deactivated event fired");
            });
        }
    }
}



Output





Click to Enlarge




Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Saturday, June 01, 2013

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250