none
WPS: example of data binding from multiple sources? RRS feed

  • Question

  • Hello.

    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.

    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.

    Thank you.

    Edit: 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?

    • Edited by KNERDY Thursday, November 30, 2017 1:33 AM
    Thursday, November 30, 2017 1:14 AM

All replies

  • Hi KNERDY,

    Thank you for posting here.

    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.

    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=-2147217396

    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-resource

    Beat Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 1, 2017 6:04 AM
    Moderator
  • Those seem to be very poor examples
    Tuesday, December 5, 2017 5:18 PM
  • Hi KNERDY,

    As you mentioned C# and XAML, I don't know if your project is a WPF project or UWP project. Since these two kinds of projects have some differences in XAML syntax, so could you provide more informaiton about your project so I can give specific suggestions?

    What's more, I think both multi binding or single binding is ok, based on how you define your data model. We can have further discussion if we have more information about your project.

    Thanks a lot,

    Charles He


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, December 8, 2017 3:17 AM