Calling Lightswitch Screen Methods from Silverlight User Control RRS feed

  • Question

  • I need to call a method on the LS screen from a custom SL control.  I tried using the code from Michael Washington's Two Ways to Call Lightswitch from a custom Silverlight Control (after converting it to VB) but, for some reason, I get an error:

    Error    1    Default property access is ambiguous between the inherited interface members 'Public ReadOnly Default Property Item(name As String) As T' of interface 'Microsoft.LightSwitch.Details.IDetailsSet(Of Microsoft.LightSwitch.Details.Client.IScreenMethod)' and 'Public ReadOnly Default Property Item(name As String) As Microsoft.LightSwitch.Details.IDetailsWithName' of interface 'Microsoft.LightSwitch.Details.IDetailsSet'.    C:\DATA\VB.NET\BRS1\MapControl\gpTools.xaml.vb    80    51    MapControl

    The code-behind looks like this:

    Imports Microsoft.LightSwitch.Presentation

    Partial Public Class gpTools
        Inherits UserControl

        Public Sub New()
        End Sub

        Private Sub CallLSMethod_Click(sender As Object, e As RoutedEventArgs)
            ' Get a reference to the LightSwitch DataContext
            Dim objDataContext = DirectCast(Me.DataContext, IContentItem)

            ' Get a reference to the LightSwitch Screen
            Dim Screen = DirectCast(objDataContext.Screen, Microsoft.LightSwitch.Client.IScreenObject)

            ' Call the Method on the LightSwitch screen
                                                  End Function)
        End Sub

    End Class

    Any idea how to make this work?

    Thanks in advance for your contribution!!


    • Edited by Isahak Thursday, July 2, 2015 9:30 PM
    Thursday, July 2, 2015 9:13 PM


  • Found the answer in Tim Leung's book, VS Lightswitch 2012!

    The last lines of code above are incorrect.  This syntax works:

    ' Call the method on the LightSwitch screen




    End Sub)


    • Marked as answer by Angie Xu Thursday, July 16, 2015 1:59 AM
    Monday, July 6, 2015 9:48 PM