Pierre Michallet

Pierre Michallet

  • NA
  • 41
  • 1.6k

Ddisplay of a List into a ListBox does not work

Feb 28 2018 10:26 AM
I am developing, for the fun, a board game from African origin called Awalé.
Briefly, it is played by 2 persons using a board with 2 rows of 6 "pits"; each "pit" contains 
4 "stones" when the game starts.
Players play in turns and the objective is to catch as many "stones" as possible according 
to rules that I have not yet implemented.
 
The UI is implemented around a 6 rows by 4 columns grid.
The problem lies around a 6 by 2 uniform grid located in row 2 column 2 of the above mentioned grid.
This uniform grid is where the number of "stones" contained in each "pit" should be displayed.
For the moment this does not work.
Although I am far from mastring it,  I have tried to follow the MVVM pattern.
All the source code is attached.
 
A few indications to make it easier to track the problem.
The UI is defined within the View.xaml file and the point of interest is a ListBox 
(lines 117 thru 133) which is in charge of displaying the "pits" content in the 6 by 2 uniform
grid mentioned above.
The ListBox is bound to a List<Pit> list called Items (see file ViewModel.cs lines 97 thru 103 where this list is declared together with a class called Pit).
 
List<Pit> is initialized within the file NewGameDelegateCommand.cs (lines 50 to 61).
A stop has been put on line 50, and I have verified that 12 elements (instances of the Pit class)  have been added to the Items List.
 
The problem.
   The content of the Items  list is not displayed when the "New game" menu is clicked.
   On the contrary, the "Score North" and "Score South" fields are correctly set to 8 and 2
   respectively  as required in lines 47 and 47 of the NewGameDelegateCommand.cs file.
 
The code has been developed with Visual Studio 2017 using .NET Framework 4.6.1.
 
Every help is welcom.
 
Thank you in advance 
 
 
 
 
 
 
 
 
 

Attachment: Awale5_-_Copie.zip

Answers (2)