I'm making a little chess game in wpf, and I'm having trouble to find the right way I should move and display pieces on the chessboard...
To draw the chessboard I use a UniformGrid
(8 * 8) which I fill on init in "code behind" with Rectangle
shapes.
Then I want to add my pieces on this grid, which are png images in a Image
control I also create in "code behind".
I thought about putting these images in the same cell of the grid as my Rectangle
controls, but I see the issue that I wouldn't be able to animate the move of a piece that way, since it will go from one location to another directly.
So I thought about adding the pieces to the parent control, and then use the RenderTransform
property to set their positions.
The thing is, I can't figure out what I have to do so that if the parent control is resized the pieces stay at the right position.
Is there a way to set the translation once and for all without having to redefine it at resize? I thought about assigning the position and size of the Rectangle
elements on the pieces control, but this doesn't seem to be doable in wpf...
Am I just doing it all the wrong way and there is a better option to do this?
Thanks for your help, any suggestions are welcome.