简体   繁体   中英

WPF Dock Panel wierd magin

I have a very simple dockpanel inside a border. But the dock panel seems to have a 1px margin on the right and bottom. I cant seem to get rid of it by setting the margin or the dockpanel nor by setting the padding of the border.

What exactly is causing it and how can I fix it without hacking it (IE negative margin on the dock panel)

<Window x:Class="WPFTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Height="350" Width="525">
    <Grid>
        <Border BorderBrush="Black" BorderThickness="2" Padding="0">
            <DockPanel Background="Blue" Margin="0"/>
        </Border>
    </Grid>
</Window>

在此处输入图片说明

No style defined on Border or DockPanel. Tried this on a brand new project and still seeing the white lines

The usual way you get gaps like that in XAML is becasue the UI is being scaled. If you can't find anything that might be scaling it ( RenderTransform in a parent, OS settings such as font size, probably other stuff), you could try playing with UseLayoutRounding and SnapsToDevicePixels .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM