Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh parent screens in lightswitch?

I want to refresh the search screens after adding new data from other screens. I've tried doing

foreach (var parentScreen in this.Application.ActiveScreens.OfType<ScreenType>())
{
     //Invoke the refresh
     parentScreen.Details.Dispatcher.BeginInvoke(() => parentScreen.Details.Commands.Refresh.Execute());
}

but it doesn't seem to work in Beta 2

like image 253
PimLong Avatar asked Dec 28 '22 19:12

PimLong


1 Answers

found it on http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/cf86ad21-48fb-48f2-87d4-e5b15f8f361c#e6879629-145a-4b18-834c-ebee0cfe1473

Unfortunately the collection of ActiveScreens does not actually contain a set of Screen objects. It contains a proxy class that you can use to access the actual screen object (this is due to different threads running in different threads). Here is some sample code that achieves what you need.

  Microsoft.LightSwitch.Client.IActiveScreen searchScreen = Application.ActiveScreens.Where(a => a.Screen is SearchCustomers).FirstOrDefault();
  searchScreen.Screen.Details.Dispatcher.BeginInvoke(() => 
  {
    ((SearchCustomers)searchScreen.Screen).Customers.Refresh();
  });
like image 119
PimLong Avatar answered Dec 30 '22 09:12

PimLong