我创建了一个带有进度条的小“ProgressWindow”。在xaml编辑器,这是确定的,没有问题。但是当我创建了一个窗口并在我的代码中显示它时,ProgressWindow显示在另一个大的白色窗口中。那是什麽?
在xaml编辑器中:
执行中:
Xaml代码:
<Window x:Class="MyStyling.Control.ProgressWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MyStyling.Control" WindowStyle="none" ResizeMode="NoResize">
<Border x:Name="Xaml_ProgressWindow_ID" Width="320" BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" Background="{DynamicResource MyBackgroundBrush}" VerticalAlignment="Center" Padding="0,0,0,20">
<Border.Effect>
<DropShadowEffect Color="Gray"
Direction="300"
BlurRadius="10"
Opacity="0.5"
ShadowDepth="10" />
</Border.Effect>
<StackPanel>
<StackPanel x:Name="XAML_SP_ProgressBar1_ID">
<Label x:Name="XAML_LBL_ProgressBar1_ID" Content="Main progress bar ..." HorizontalAlignment="Center" />
<ProgressBar x:Name="XAML_PG_ProgressBar1_ID" Height="5" Margin="20,0,19,0" Background="White" Foreground="Black" />
</StackPanel>
<StackPanel x:Name="XAML_SP_ProgressBar2_ID" Margin="0,10,0,0">
<Label x:Name="XAML_LBL_ProgressBar2_ID" Content="Secondary progress bar" HorizontalAlignment="Center" FontSize="11" />
<ProgressBar x:Name="XAML_PG_ProgressBar2_ID" Height="5" Margin="20,0,19,0" Background="White" Foreground="Black" />
</StackPanel>
</StackPanel>
</Border>
1条答案
按热度按时间svmlkihl1#
将窗口的
SizeToContent
属性设置为WidthAndHeight
,以自动调整窗口大小以适合Border
:或者将
Border
Package 在ViewBox
中,以将其拉伸到窗口的大小: