C#UWP背景色未完全填充

C#UWP背景色未完全填充,c#,windows,xaml,uwp,C#,Windows,Xaml,Uwp,在MainPage.xaml中,我有一个网格 <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.2*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <vi

在MainPage.xaml中,我有一个网格

<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.2*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <views:SidePage Grid.Column="0" />
        <views:ContentPage Grid.Column="1" />
</Grid>

正如您所看到的,“测试”在白色部分。

修复了它

我通过将ContentPage包装在单独的网格中来修复它

这是新的MainPage.xaml

<Page
    x:Class="MediaPlayer.MainPage"
    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"
    xmlns:views="using:MediaPlayer.Views"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.2*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <views:SidePage Grid.Column="0" />
        <Grid Grid.Column="1">
            <views:ContentPage />
        </Grid>
    </Grid>
</Page>


网格包裹
堆叠面板
。看起来它不尊重父级的宽度。在ContentPage中用网格包装StackPanel不会改变它。在主页面中使用StackPanel包装网格也不起作用。背景色与宽度不匹配。
public ContentPage()
{
    InitializeComponent();
    Background = new SolidColorBrush(StaticColors.ContentBackgroundColor);
}
        public static readonly Color ContentBackgroundColor = Color.FromArgb(150, 0, 0, 60);
<Page
    x:Class="MediaPlayer.MainPage"
    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"
    xmlns:views="using:MediaPlayer.Views"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.2*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <views:SidePage Grid.Column="0" />
        <Grid Grid.Column="1">
            <views:ContentPage />
        </Grid>
    </Grid>
</Page>