I am working on an application for a company - cannot disclose full information on the project but I will try and be descriptive enough. I have a WPF project (C#), I use MVVM, where a user logins in, makes a selection on a combobox, checks Togglebuttons and saves that link by pressing a Button.
For your understanding I will make an example of a team pf players. Combobox has Team A,B,C and the Togglebuttons are the names of the players. User selects Team A and selects players John and Dave for that team and presses save - this is saved to an xml file. When the Togglebutton is checked, it changes color. Now when the user opens the App again, selects Team A from the Combobox, the players that were already selected should appear as checked - change color.How can I achieve this using MVVM? The ViewModel side works fine - I can get the names of players that are linked to current selection of Combobox but I don't know how to bind this to the Togglebutton.
P.S. this link http://www.dotnetlead.com/wpf-organization-chart/application-and-source-code is an example I took this from, it will help you understand what I'm talking about - the selection of the button especially.
Your help will be highly appreciated. Even if it is a theoretical explanation I will figure out the code.
Av MxPosted Feb 21, 2017, 5:49 AM
Asma KhalidPosted Feb 21, 2017, 5:47 AM
You do have .cs file attach with every .xaml file that makes it VM. You can do the loop thing in the attached .cs file.
Av MxPosted Feb 21, 2017, 5:42 AM
Asma KhalidPosted Feb 21, 2017, 5:36 AM
Av MxPosted Feb 21, 2017, 5:25 AM
Asma KhalidPosted Feb 21, 2017, 5:21 AM
Av MxPosted Feb 21, 2017, 4:12 AM
Asma KhalidPosted Feb 21, 2017, 3:14 AM
Since you are storing data in xml this means you need to structure you XML in amanner that while saving information team name is parent node and selected players are child nodes. Then when you select team A from combobox you can highlight those player that are stored under team A in the result XML