Articles → LIGHT SWITCH 2011 → Screen Lost Focus Event In Lightswitch 2011
Screen Lost Focus Event In Lightswitch 2011
Software Requirement
- Visual studio 2010 is installed on your machine.
- Visual Studio 2010 service pack 1 is installed on your machine.
- Microsoft Visual Studio Light switch 2011 is installed on your machine.
Prerequisite Knowledge
- Basics about lightswitch.
- How to create screens in lightswitch?
- How to create lightswitch project using visual studio?
- What are screens event?
Steps Of Execution
- Create a new project
- Add 2 screens
- Add code for screen’s lost focus
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