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
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();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With