下面顯示了我的wpf應用程序的一個簡單部分,您可以在其中看到兩個邊框(1.和2.)。WPF:兩個具有純色背景的邊框在頂部有一個醜陋的像素行(與父面板的背景合併顏色)
在3.你可以看到一個精簡版紅線(這是我的問題)。該行從未(明確)在xaml代碼中定義。紅色背景僅在父母網格中定義,並在邊框元素的頂部閃爍。下面是我的代碼:
<Window
x:Class="BgColorBug.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="200"
WindowStartupLocation="CenterScreen"
>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="1" Background="Red">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Border
Grid.Row="0"
Height="4" Background="#1F1F1F" />
<Border
Grid.Row="1"
Background="#777777"
>
<WrapPanel
Orientation="Horizontal"
HorizontalAlignment="Right"
>
<Button Padding="7" Margin="7">Hello</Button>
<Button Padding="7" Margin="7">World</Button>
</WrapPanel>
</Border>
</Grid>
</Grid>
當我定義修復行高度(而不是自動值),那麼紅線沒有顯示,所以我認爲這是一個顯示問題(由側邊界1.也有紅線)。