Search code examples
c#xamluwpchess

How do I Draw a Chessboard using XAML?


I am working on a project that requires me to develop an application using the Universal Windows Platform (UWP). I have no prior knowledge of developing UWP apps and XAML is completely new to me. Thankfully however, I am competent at writing in C#.

The project I am working on involves recreating the Tafl Board games - Hnefatafl, Brandubh, Tablut, etc.

Now, while I'm fairly confident in my ability to create the underlying logic for the game, I find myself bamboozled when it comes to creating the interface using XAML.

Several different chessboards will need to be rendered: 7x7, 9x9 and 11x11.

So my question is two-fold.

  1. How do I create a chessboard in XAML that will scale appropriately to different window/display sizes and be able to be backed by a grid behind the scenes (i.e. The application can detect which square of the board is touched, etc)
  2. How do I go about rendering a different board depending on the game type selected?

Apologies if this is a terrible question but googling hasn't helped me a whole lot and StackOverflow has always been a great source of information.


Solution

  • You might want to try out the RelativePanel control and use different coloured rectangles for the tiles. This would resize for different screen sizes.