在Visual Studio中的設計過程中,WPF窗口背景顏色是白色的,但是當我調試應用程序時,它是黑色的。爲什麼?WPF窗口在VS設計器中的顏色與調試時不同?
這裏是我的.xaml代碼:
<Controls:MetroWindow x:Class="XLTT.Views.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
ShowTitleBar="False"
WindowStartupLocation="CenterOwner"
ShowCloseButton="False"
ResizeMode="NoResize"
WindowStyle="ToolWindow"
Height="320"
Width="400"
Title="About" >
<!-- your content here -->
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Name="lblAppName" Margin="10" TextWrapping="Wrap" Text="Application Name :" VerticalAlignment="Stretch" FontSize="24" FontFamily="Segoe UI Light" Foreground="#FFF53800"/>
<TextBlock Name="lblBuild" Margin="10" TextWrapping="Wrap" Text="Build :" VerticalAlignment="Top" Grid.Row="1" FontSize="16" FontFamily="Segoe UI Light"/>
<TextBlock Name="lblOwner" Margin="10" TextWrapping="Wrap" Text="Owner :" VerticalAlignment="Top" Grid.Row="2" FontWeight="Bold" FontFamily="Segoe UI Light" FontSize="16" />
<TextBlock Name="lblLicense" Margin="10" TextWrapping="Wrap" Text="License" VerticalAlignment="Top" Grid.Row="3" FontWeight="Bold" Foreground="#FFEA1818" FontFamily="Segoe UI Light" FontSize="16" />
<Button Name="btnOk" Content="OK" HorizontalAlignment="Right" Margin="0,0,10,4" VerticalAlignment="Bottom" Width="94" Grid.Row="4" Click="btnOk_Click" Height="40"/>
</Grid>
請閱讀我的更新,並嘗試它! – Smartis