Articles → LIGHT SWITCH 2011 → Autorefresh Lightswitch Screen In Lightswitch 2011

Autorefresh Lightswitch Screen In Lightswitch 2011






Software Requirement




  1. Visual studio 2010 is installed on your machine.
  2. Visual Studio 2010 service pack 1 is installed on your machine.
  3. Microsoft Visual Studio Light switch 2011 is installed on your machine.

Prerequisite Knowledge




  1. What is lightswitch?
  2. What are screens and entities in lightswitch?
  3. How to create an entity in lightswitch?
  4. How to create screens in lightswitch?

Creation Of New Project




Picture showing the project structure of the lightswitch project
Click to Enlarge


Add Employee Entity In The Project




Picture showing the schema of Employee table in lightswitch
Click to Enlarge


Add Editable Grid Screen




Picture showing the editable grid screen added in the project
Click to Enlarge


Add Records In The Table




Picture showing records added in the lightswitch project
Click to Enlarge


Add Timer In The Screen




using System;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using System.Windows.Threading;
using Microsoft.LightSwitch.Threading;

namespace LightSwitchApplication {
	public partial class EditableEmployeesSetGrid {
		partial void EditableEmployeesSetGrid_InitializeDataWorkspace(List < IDataService > saveChangesTo) {
			Dispatchers.Main.BeginInvoke(() = >{
				Timer.Tick += new EventHandler(Each_Tick);
				Timer.Start();
			});

		}

		private static readonly DispatcherTimer Timer = new DispatcherTimer() {
			Interval = TimeSpan.FromSeconds(5) // Create a timer to refresh screen
		};

		private void Each_Tick(object sender, EventArgs e) {
			Dispatchers.Main.BeginInvoke(() = >{
				EmployeesSet.Refresh();
			});
		}
	}
}







Posted By  -  Ritesh Arya
 
Posted On  -  Wednesday, September 19, 2012

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250