Wpf 控件未显示在groupbox下

Wpf 控件未显示在groupbox下,wpf,xaml,Wpf,Xaml,我的xaml文件中有一个groupbox,其中包含一个标签、图像、两列的DataGrid、一个文本框和progressbar。但是,当我编译表单并运行它时,不会显示来自此groupbox的控件。但是,将显示来自其他GroupBox的控件 这是我在xaml中的分组框: <GroupBox HorizontalAlignment="Left" Height="400" Margin="25,150,0,0" VerticalAlignment="Top" Width="411" BorderB

我的xaml文件中有一个groupbox,其中包含一个标签、图像、两列的DataGrid、一个文本框和progressbar。但是,当我编译表单并运行它时,不会显示来自此groupbox的控件。但是,将显示来自其他GroupBox的控件

这是我在xaml中的分组框:

<GroupBox HorizontalAlignment="Left" Height="400" Margin="25,150,0,0" VerticalAlignment="Top" Width="411" BorderBrush="#FF0788F3" Style="{DynamicResource GroupBoxStyle1}" Grid.RowSpan="2">
            <StackPanel Margin="-4,1,-5,-7" RenderTransformOrigin="0.5,0.5">
                <Label Content="Text" x:Name="label4" Margin="6,40,242,0" VerticalAlignment="Top" FontFamily="Ebrima" FontSize="16" Padding="5" Background="#FF3053B0" FontWeight="Bold"/>
                <Image x:Name="Image" HorizontalAlignment="Left" VerticalAlignment="Top" Width="62" Height="42" Margin="185,-30,0,0" />
                <DataGrid x:Name="InstallableGrid" Margin="10,15,0,0" HeadersVisibility="Column" VerticalAlignment="Top" FontSize="14" Height="138" Background="#FFF5F3C7" RowBackground="#FF37AEC9" AlternatingRowBackground="LightBlue" CanUserAddRows="False"  KeyboardNavigation.TabNavigation="None" AutoGenerateColumns="True" IsReadOnly="True" VirtualizingPanel.VirtualizationMode="Standard" HorizontalGridLinesBrush="Black" HorizontalAlignment="Left" Width="333" SelectionChanged="InstallableGrid_SelectionChanged">
                    <DataGrid.Columns>
                        <DataGridCheckBoxColumn Header="Select" ElementStyle="{StaticResource CheckBoxStyleInverted}"   />
                    </DataGrid.Columns>
                </DataGrid>
                <TextBox x:Name="PBarTimer" Background="#FFF5F3C7" Foreground="Red" HorizontalAlignment="Left" Height="20" Margin="10,45,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="55" FontSize="14" Padding="1,-1,1,1" RenderTransformOrigin="-0.249,0.84"/>
                <ProgressBar x:Name="PBar" Background="#FFF5F3C7" HorizontalAlignment="Left" Height="20" Margin="75,-20,0,0" VerticalAlignment="Top" Width="268" IsIndeterminate="True" RenderTransformOrigin="0.596,0.765"/>

            </StackPanel>
        </GroupBox>


PS:我是wpf的完全初学者,我基本上是一个Linux人,所以我在这里犯的问题可能非常愚蠢,我曾尝试用谷歌搜索这个问题,但找不到任何帮助

您是否在GroupBoxStyle1中设置了OverridesDefaultStyle=“True”?删除它并尝试。wpf中有布局面板,因此您不需要太多的边距:)