Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would recommend 2 things:</p> <p>First, use some loops in your code-behind to generate all your rectangles. You have about 64 of them hard-coded. Code behind could really reduce the size of that XAML file.</p> <p>XAML:</p> <pre><code> &lt;UniformGrid x:Name="_uniformGrid" Rows="8" Columns="8"/&gt; </code></pre> <p>CodeBehind: (a little complicated because the rows alter white/black, but the code below works...)</p> <pre><code>private void InitializeUniformGrid() { for (int i = 0; i &lt; 4; i++) { for (int j = 0; j &lt; 4; j++) { _uniformGrid.Children.Add(new Rectangle { Fill = Brushes.Black, Stroke = Brushes.Black }); _uniformGrid.Children.Add(new Rectangle { Fill = Brushes.White, Stroke = Brushes.Black }); } for (int k = 0; k &lt; 4; k++) { _uniformGrid.Children.Add(new Rectangle { Fill = Brushes.White, Stroke = Brushes.Black }); _uniformGrid.Children.Add(new Rectangle { Fill = Brushes.Black, Stroke = Brushes.Black }); } } } </code></pre> <p>Second, to solve your main problem, you need to specify a Height and Width for your ChessBoardView.</p> <p>Do this (change the 500 to whatever width and height you really need):</p> <pre><code>Height="500" Width="500" </code></pre> <p>The following will only set the height and width while in design view, not when your code is running:</p> <pre><code>d:DesignHeight="300" d:DesignWidth="300" </code></pre> <p>Your resulting XAML should look like this:</p> <pre><code>&lt;UserControl x:Class="Chess_Piece_Viewer.Views.ChessBoardView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Height="300" Width="300" d:DesignHeight="300" d:DesignWidth="300"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload