从 Lightswitch 屏幕返回值到 Silverlight 控件

发布于 2024-12-26 04:05:44 字数 748 浏览 5 评论 0原文

我已经研究了许多 Silverlight 控件能够从 Lightswitch 屏幕调用方法并访问数据集合的示例。

我想要访问当前在 silverlight 控件上查看的编辑表单中记录的 ID 字段,以便我可以在另一个系统中查找相关数据。

我尝试在 Common 项目中实现一个返回字符串的接口,并在 Silverlight 中使用以下内容来访问它。自定义类是一个名为 Silverlight Bridge 的接口,可以成功调用屏幕上的方法,但是似乎无法获取返回值。

    var objDataContext = (IContentItem)this.DataContext;
    var Screen = (Microsoft.LightSwitch.Client.IScreenObject)objDataContext.Screen;

    string myVar = "Empty";

    var SilverlightBridge = (LightSwitchApplication.UserCode.ISilverLightBridge)Screen;

    Screen.Details.Dispatcher.BeginInvoke(() =>
    {
        myVar = SilverlightBridge.GetVehicleID();

    });

    MessageBox.Show(myVar) ;

myVar 似乎从未被设置。

是否有我可以指出的示例代码或任何人都可以建议的解决方案?

I have waded through many examples of Silverlight controls being able to invoke methods and access data collections from a Lightswitch Screen.

I am wanting to access the ID field of the record in the edit form I'm currently viewing on my silverlight control so I can look up relevant data in another system.

I have tried implementing an interface in the Common project that returns a string and using the following in my Silverlight to access it. The custom class is an interface called Silverlight Bridge and successfully can invoke methods on the screen, however, just can't seem to get a return value back.

    var objDataContext = (IContentItem)this.DataContext;
    var Screen = (Microsoft.LightSwitch.Client.IScreenObject)objDataContext.Screen;

    string myVar = "Empty";

    var SilverlightBridge = (LightSwitchApplication.UserCode.ISilverLightBridge)Screen;

    Screen.Details.Dispatcher.BeginInvoke(() =>
    {
        myVar = SilverlightBridge.GetVehicleID();

    });

    MessageBox.Show(myVar) ;

It would seem that the myVar is never being set.

Is there example code that I could be pointed to or a solution that anyone could suggest?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尛丟丟 2025-01-02 04:05:44

使用 LightSwitch,您希望简单地绑定到集合,然后通过绑定获取要由 Silverlight 控件使用的值。

在您的情况下,“我当前正在查看的编辑表单中的记录的 ID 字段”是集合中的值(可能是集合的“.SelectedItem”)。

您希望将 Silverlight 控件绑定到该值。

您只想使用您所描述的模式来通过用户在 Silverlight 控件上引发事件来启动事件。

With LightSwitch you want to simply bind to collections and then get the values, to be consumed by your Silverlight control, through the bindings.

In your case the "ID field of the record in the edit form I'm currently viewing" is a value in a collection (probably the ".SelectedItem" of a collection).

You want to bind your Silverlight control to this value.

You only want to use the pattern you decribed for initiating events by the user raising it on the Silverlight control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文