locked
How do I call a Lightswitch Client method from ScreenChildWindow? RRS feed

  • Question

  • I have a customer Add/Edit ScreenChildWindow created with Silverlight.

    I then overrode the "+" button to call myScreenChildWindow.
    From myScreenChildWindow I created a Closed() event to trigger a method from the client screen that called it.

    This is the code I'm trying to get to work but I get a NullRef error. I already have variations of the same code that works but not in the same scenario I want to use now...

    public void CallLightswitchMethod()
            {
                var parent = (System.Windows.Controls.Primitives.Popup)this.Parent;
                var objDContext = (IContentItem)parent.DataContext;
                var Scrn = (IScreenObject)objDContext.Screen;
                var dispatcherOp = Scrn.Details.Dispatcher;
                dispatcherOp.BeginInvoke(() =>
                 {
                     Scrn.Details.Methods["SaveStuff"].CreateInvocation(null).Execute();
                 });
    }

    Friday, October 10, 2014 1:28 AM