Av Mx

Av Mx

  • NA
  • 16
  • 1.9k

Bind selectedIndex of combobx to Togglebutton c#

Feb 17 2017 5:47 AM
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.

Answers (8)