Hello,
I have a Grid displaying rectangles. The grid can be resized and is supposed to display adjacent rectangles without any gap.
However, depending on the actual size of the grid, blank lines appear between the rows and columns of the grid. I guess this is to make up for sizes where the width isn't a multiple of the number of columns, or the height isn't a multiple of the number of rows.
The following XAML code demonstrates this:
<Window x:Class="test.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Rectangle Grid.Column="0" Grid.Row="0" Fill="DarkBlue"></Rectangle>
<Rectangle Grid.Column="1" Grid.Row="0" Fill="DarkOrange"></Rectangle>
<Rectangle Grid.Column="0" Grid.Row="1" Fill="DarkBlue"></Rectangle>
<Rectangle Grid.Column="1" Grid.Row="1" Fill="DarkBlue"></Rectangle>
</Grid>
</Window>
How can I prevent those blank lines? If one or some of the columns/rows are slightly larger than others is not really a problem. I'd like to keep the markup simple.
I unsuccessfully tried Stretch, Fill, putting the grid in a Viewbox, ShowGridLines=False, Width=Auto, etc.
I'm unable to post pictures (min 10 reputation points), sorry. I uploaded it to http://f.imagehost.org/0157/wpf.png .