Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SizeToContent paints an unwanted border

Whenever I try to make a window and I set the SizeToContent to WidthAndHeight, on opening the window correctly sizes to it's contents, but it adds a small border to the right and the bottom. On resizing this disappears, and when using a set height and width this problem also doesn't occur.

This is a sample of what I mean:

enter image description here

You could say this is not a huge problem, though I find it makes my application look unprofessional, especially when I need to present this. Does anybody know why this is happening, or whether there is a workaround? I am coding this project in C#.

XAML Code:

<Window x:Class="FPricing.InputDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="InputDialog" Width="400" Height="300" SizeToContent="WidthAndHeight">
    <StackPanel>
        <Label x:Name="question">?</Label>
        <TextBox x:Name="response"></TextBox>
        <Button Content="OK" IsDefault="True" Click="Button_Click" />
    </StackPanel>
</Window>

Values are passed on on creation of the class.

However I experience this problem on every window I have ever created, even without custom underlying code.

like image 786
Kryptoxx Avatar asked May 03 '13 10:05

Kryptoxx


1 Answers

<Window UseLayoutRounding="True" /> works for me.

like image 183
smg Avatar answered Sep 17 '22 22:09

smg