[英]C# UWP How to set the background behind the application to black
如果用戶單擊我的應用程序的一角並調整大小,應用程序將保持相同的大小,但后面的區域會擴大。 最大化相同。 后面的區域是白色的。
理想情況下,我想完全禁用調整大小! 但是,鑒於我無法弄清楚如何阻止它,我該如何將后面的區域更改為 black 。
如果我將頁面更改為背景 =“黑色”,則白色會保持不變,並且有一個黑色區域偏移並且完全錯誤。 圖片1
圖 2 是我使用下面的 XAML 得到的結果。 這也是我通過最大化得到的,它只是全屏。
附帶問題:有沒有辦法只擁有不會改變大小的應用程序?
抱歉.. 我以為這將是一個非常簡單的回答。
[
這是開放的 XAML。 我刪掉了頁面資源中的故事板……信息太多
<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"
然后在我弄清楚另一個之后將背景設置為黑色
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.