C# UWP 如何设置应用程序背后的背景为黑色

C# UWP How to set the background behind the application to black

如果用户点击我的应用程序的一角并调整大小,应用程序将保持相同大小,但后面的区域会扩大。最大化相同。后面的区域是白色的。

理想情况下,我想完全禁用调整大小!但是,鉴于我一直无法弄清楚如何阻止它,我该如何将后面的区域更改为黑色

如果我将页面更改为 Background="Black",白色会保留,并且有一个黑色区域偏移,这是完全错误的。图1

图2是我用下面的XAML得到的。这也是我用最大化得到的,它只是全屏。

附带问题:有没有办法只拥有不会改变大小的应用程序?

抱歉.. 我认为 这将是一件非常简单的事情来回答。


[

这是开头XAML。我删掉了 Pages 资源中的故事板……信息太多

<Page
x:Class="ScqWander.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ScqWander"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Width="1104"    Height="700" 
MaxWidth="1104" MinHeight="700"    
Loaded="Page_Loaded"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.Resources></Page.Resources>

<Border x:Name="AppContainerForCentering"  
        Width="1104" Height="696"
        BorderBrush="GreenYellow" 
        BorderThickness="4" >

    <Grid x:Name="MainBoard" Background="Black" 
      Height="690" Width="auto"
      HorizontalAlignment="Center" VerticalAlignment="Center"          
     >   
        <Grid.RowDefinitions>
            <RowDefinition Height="70"/>
            <RowDefinition Height="35"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="125"/>
            <RowDefinition Height="0*"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10"/>
            <ColumnDefinition Width="1084"/>
            <ColumnDefinition Width="10"/>
            <ColumnDefinition Width="0"/>
        </Grid.ColumnDefinitions>

        <Grid x:Name="gridMainDesignArea"  Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Height="auto" Width="auto" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40"/>
                <ColumnDefinition Width="230"/>
                <ColumnDefinition Width="780"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Image x:Name="BabyMonOnBar" Width="28" Height="28"
            Source="Assets/Images/Play/MonsterBaby.png" 
            Grid.Column="2"                 
            HorizontalAlignment="Left" VerticalAlignment="Top">
                <Image.RenderTransform>
                    <CompositeTransform ScaleX="1.0" ScaleY="1.0"/>
                </Image.RenderTransform>
            </Image>               

                all the other XAML goes here
    <Grid>
   <Border> 
  <Page>

我找到了答案。我在第一个标签中设置宽度和高度,假设那是正确的位置。它是!

我不知道的是这个

  • 删除 宽度="" 和 高度=" "

  • 替换为d:DesignWidth="1194" d:DesignHeight="758"

然后在我弄清楚另一个后将背景设置为黑色