WPS:来自多个来源的数据绑定示例? [英] WPS: example of data binding from multiple sources?

查看:183
本文介绍了WPS:来自多个来源的数据绑定示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

我正在学习C#并在一些帮助下找出基本数据绑定到XAML以更改值在我需要设置的字段中。

I am learning C# and with some help, figured out basic data binding to XAML to change the values in the fields I need to set up.

我现在意识到我需要从多个来源做数据绑定,我学到的方法确实如此似乎与此不兼容。在最后的项目中,我将通过USB或RS232将大约四台设备连接到计算机。我打算为每个设备创建一个
类,它与设备建立连接,然后发送或接收来自它们的数据。

I realize now I need to do data binding from multiple sources, and the method I learned does not seem to be compatible with that. In a final project, I will have about four devices connected to the computer via USB, or RS232. It is my intention to make a class for each device which makes the connection to the device, then sends, or receives data from them.

我在想我还应该创建另一个执行所有数据收集的类,然后反过来影响显示字段中的值。

I am thinking I should also make another class which does all the data collection, then in turn affects the values in the display fields.

 至于例子,我没有看到太多帮助我的方式。也许我在寻找错误的条款?也许有多个观点?

 As for examples, I am not seeing much in the way which is giving me much help. Maybe I am searching for the wrong terms? Maybe multiple views?

任何帮助和建议表示赞赏。

Any help, and advice appreciated.

谢谢。

编辑:思考之后,如果只是一个类正在做所有数据绑定到XAML页面,然后看起来我不需要做多个数据绑定,对吗?

After thinking about it, if only one class is doing all the data binding to the XAML pages, then it looks like I do not need to do multiple data binding, correct?

推荐答案

嗨KNERDY,

Hi KNERDY,

感谢您在此发帖。

如果您想使用c#代码将数据从资源绑定到xml,您可以使用Application.Resources添加多个资源,然后使用您在c#代码中定义的字段值在代码中设置它。

If you want to bind data from resources to xml using c# code, you could use Application.Resources to add multi resources and then set it in code with the value of fields you defined in c# code.

请查看有关Application.Resources的MSDN文章以供参考。

Please check the MSDN article about Application.Resources for your reference.

https://msdn.microsoft.com/en-us/library/system.windows.application.resources%28v=vs.110%29.aspx?f=255&MSPPError=-214721 7396

如果要直接绑定XMAL中的资源,可以参考StackoverFlow中的线程。

If you want to bind resources in XMAL directly, you could refer to the thread in StackoverFlow.

https://stackoverflow.com/questions/28893235/converter-parameter-multi-binding-static-资源

Beat Regards,

Beat Regards,

Wendy


这篇关于WPS:来自多个来源的数据绑定示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆