Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi all:-)

I have a 2 dimensional array (8x8) of integers which is representing a chessboard.

the integers are identifiers of a chess-figure.

Now i want to display this chessboard. Important is: When i later change an element of the array, i want that this change is automatically displayed.

Does anybody know how this can be achieved?

(What i already can, is displaying the chessboard. But i have no idea how to achieve the binding part. Searched alot (and over 8 hours ) but i am new to wpf....;-) )

Please help:-)
Posted
Comments
Xmen Real 3-May-15 21:09pm    
Your question is incomplete. How do you want to display it on app ? What controls are you using ? Please complete your question first. :)
Member 10781325 4-May-15 16:46pm    
ok, here is a brief summery: the chessboard is a control, which consists of a grid with 8 columns and 8 rows (= 64 fields). In each of this grid-fields is another control, which i called Field. A field consists only of an image. ( the image with the figure, which stays on this field.) It also has a dependency property called FigureNumber.
If this number changes, i load the right image.

In the code behind of the chessboardcontrol, i have an 8x8 array (arrChessBoard) of ChessFigures (which are the figurenumbers, these are extended bytes: INotifypropertychanged, see code). What i now want: if i change byte (chessfigure) in this array, the right image should appear in the chessboardcontrol. I set the figurenumbers of the arrChessBoard in the contructor of the chessboardcontrol, but no figure is showed...

Here is my code:

the first of the 64 fields of the schachboardcontrol (i left out grid.row = 0 and grid.column = 0):

schach:field figurenumber="{Binding arrChessBoard[0][0], Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" removed="BurlyWood">

public class ChessFigure : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private byte _Value;
public byte Value
{
get { return _Value; }
set { _Value = value; OnPropertyChanged("Value"); }
}

void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
I dont know, why this does not function... There simply does not appear an image.
When i debug the program, i noticed, that the handler is always null and the event is never fired. But i dont know why;-)^^

thx for your time!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900