-2

I am learning WPF and doing some kind of game. The bottom line is that there are 4 skills, and at each level you can learn only one skill from a column, but if you want, you can change it to another one in that column. Each skill is attached from a collection from a view model. In addition, after pressing the highlighted skill is highlighted. If the selection has been changed, the previous one becomes gray and the new one is highlighted. And all this is then written to an array List<(Class for skill)>.This screenshots is for example.How can I do it? I use MVVM Light.

Gif viewmodel

Ricarnev
  • 27
  • 6

1 Answers1

0

I don't think you've provided enough code to really help, but I can see what you're trying to do.

What you should do instead of maintaining two lists is to have each list (so a total of 4) be encapsulated in a class which has the following properties:

  • SelectedItems ObservableCollection<T>
  • AvailableItems List<T>
  • Name string
  • Image ???

Bind the SelectedItems of your view construct to the SelectedItems of the class, and the datasource for the view construct to the AvailableItems list. Then you should hook into the collection changed event for each row, and put your logic to restrict the number of column values there.

Marisa
  • 732
  • 6
  • 22
  • Can I ask you, how to organize this grid? Listview with buttons/usercontrols or something else? – Ricarnev Nov 28 '18 at 12:51
  • Probably a listbox. Take a look at https://stackoverflow.com/questions/10172712/listbox-displaying-horizontal-images-wpf and https://stackoverflow.com/questions/11142976/how-to-support-listbox-selecteditems-binding-with-mvvm-in-a-navigable-applicatio, these two combined should give you what you need. – Marisa Nov 28 '18 at 13:26