Chessboard in WPF

后端 未结 5 1101
情深已故
情深已故 2021-01-03 07:33

For years I\'ve developed with Winforms, now I want to switch to WPF and make a chessboard. Unfortunately I have no idea where to start. Using WPF makes me very unsure, I\'m

5条回答
  •  滥情空心
    2021-01-03 07:54

    No, I don't think you're missing anything at all. That is a good start.

    Create a grid then add the columns and rows. Then drop a rectangle into alternating cells (or an image). I would create a style for the rectangle's fill color and stroke. This allows you to change the background color in one location (the style definition) rather than for each cell you need to change.

    Here is a very basic board using grid. Note I did not hardcode the size of the rows and columns. Tis will keep everything proportionate and allow the board to scale.

        
        
            
            
            
            
            
            
            
            
        
        
            
            
            
            
            
            
            
            
        
        
    
    

提交回复
热议问题