日期:2014-05-18  浏览次数:21041 次

WPF:谁来运行一下这个代码,发现了一个奇怪现象。
为什么Border和Label,这两个控件,没有对齐?而是位置错开了一个像素?

为什么 Border的大小是21*20?本来应该是20*20。

XML code


<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        
        <Border Grid.Row="1" Width="20" Height="20" Background="Green" BorderBrush="Transparent"></Border>
        <Label  Grid.Row="2"  Width="20" Height="20" Background="Green"></Label>
    </Grid>
    
</Window>




------解决方案--------------------
探讨

如何解决是好?

引用:

发现了这种情况