0

我想拉伸这个窗口的 Groupbox(高度)。我无法让它工作。我究竟做错了什么?我想要的是组框延伸到窗口的高度,但第一列没有延伸。

    <!-- PLAYER A -->
    <Border Grid.Row="0" Grid.Column="0" x:Name="PlayerA" Height="145" VerticalAlignment="Center">
        <Grid Height="145" VerticalAlignment="Top">
            <GroupBox x:Name="grpPlayerA" Header="Player A" Margin="10,14,0,0" RenderTransformOrigin="0.035,-0.717" Height="127" VerticalAlignment="Top">
                <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Label x:Name="lblArtistA" Content="VENGABOYS" HorizontalAlignment="Left" Margin="3,3,0,0" VerticalAlignment="Top"/>
                    <Label x:Name="lblTitleA" Content="TO BRAZIL" HorizontalAlignment="Left" Margin="3,27,0,0" VerticalAlignment="Top"/>
                    <ProgressBar x:Name="prgPlayerA" HorizontalAlignment="Left" Height="15" Margin="5,53,0,0" VerticalAlignment="Top" Width="212"/>
                    <Image x:Name="imgPlayerA" HorizontalAlignment="Left" Height="62" Margin="220,6,0,0" VerticalAlignment="Top" Width="81"/>
                    <Button x:Name="btnPlayerAPlay" Content="Play" HorizontalAlignment="Left" Margin="5,79,0,0" VerticalAlignment="Top" Width="75"/>
                    <Button x:Name="btnPlayerAPauze" Content="Pauze" HorizontalAlignment="Left" Margin="92,79,0,0" VerticalAlignment="Top" Width="74"/>
                    <Button x:Name="btnPlayerAStop" Content="Stop" HorizontalAlignment="Left" Margin="178,79,0,0" VerticalAlignment="Top" Width="76"/>

                </Grid>
            </GroupBox>

        </Grid>
    </Border>

    <!-- PLAYER B-->
    <Border Grid.Row="0" Grid.Column="1" x:Name="PlayerB">
        <GroupBox x:Name="grpPlayerB" Header="Player B" Margin="0,14,16,0" Height="127" VerticalAlignment="Top">
            <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                <Label x:Name="lblArtistB" Content="VENGABOYS" HorizontalAlignment="Left" Margin="3,3,0,0" VerticalAlignment="Top"/>
                <Label x:Name="lblTitleB" Content="TO BRAZIL" HorizontalAlignment="Left" Margin="3,27,0,0" VerticalAlignment="Top"/>
                <ProgressBar x:Name="prgPlayerB" HorizontalAlignment="Left" Height="15" Margin="5,53,0,0" VerticalAlignment="Top" Width="212"/>
                <Image x:Name="imgPlayerB" HorizontalAlignment="Left" Height="62" Margin="220,6,0,0" VerticalAlignment="Top" Width="81"/>
                <Button x:Name="btnPlayerBPlay" Content="Play" HorizontalAlignment="Left" Margin="5,79,0,0" VerticalAlignment="Top" Width="75"/>
                <Button x:Name="btnPlayerBPauze" Content="Pauze" HorizontalAlignment="Left" Margin="92,79,0,0" VerticalAlignment="Top" Width="74"/>
                <Button x:Name="btnPlayerBStop" Content="Stop" HorizontalAlignment="Left" Margin="178,79,0,0" VerticalAlignment="Top" Width="76"/>

            </Grid>
        </GroupBox>
    </Border>

    <!-- HITLIJST -->
    <Border Grid.Row="1" Grid.Column="0" x:Name="Hitlijst" VerticalAlignment="Top" Margin="0,0,0,28">
        <Grid VerticalAlignment="Top">
            <Grid.RowDefinitions>
                <RowDefinition Height="0*"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <GroupBox x:Name="grpPlaylist" Header="Hitlijst" Margin="10,0" Grid.RowSpan="2" Height="275">
                <Grid VerticalAlignment="Top">
                    <ListBox x:Name="lbxHitlijst" Height="242" Margin="10,10,10,0" VerticalAlignment="Top">
                        <ListBoxItem Background="#FFF55F19" Content="1. Vengaboys - To Brazil (3:19)"/>
                        <ListBoxItem Background="#FFF91A1A" Content="2. Total Touch - Doo Be La Dee (3:60)"/>
                        <ListBoxItem Content="3. ATB - 9 PM Till I Come (3:33)"/>
                    </ListBox>

                </Grid>
            </GroupBox>

        </Grid>
    </Border>

    <Border Grid.Row="1" Grid.Column="1" x:Name="Info">
        <Grid>
            <GroupBox x:Name="grpInfo" Header="Info" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Height="282" Width="324">
                <Grid>
                    <TextBlock x:Name="txtLyrics" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Lyrics" VerticalAlignment="Top" Height="119" Width="292"/>
                    <GroupBox x:Name="grpInfoInfo" Header="Gegevens" HorizontalAlignment="Left" Margin="10,134,0,0" VerticalAlignment="Top" Height="116" Width="292">
                        <Grid>
                            <Label x:Name="lblAlbum" Content="ALBUM: Hitzone 1" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.149,0.231"/>
                            <Label x:Name="lblYear" Content="JAAR: 1992" HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" RenderTransformOrigin="0,0.269"/>
                            <Label x:Name="lblArtists" Content="ARTIEST(EN): Vengaboys" HorizontalAlignment="Left" Margin="10,62,0,0" VerticalAlignment="Top"/>

                        </Grid>
                    </GroupBox>

                </Grid>
            </GroupBox>

        </Grid>
    </Border>
    <GroupBox x:Name="grpHitlijst" Header="Hitlijst --" Grid.ColumnSpan="2" Grid.RowSpan="2" Margin="0,0,10,10"/>
</Grid>

让它工作会很棒,在此先感谢!

4

2 回答 2

1

如果您希望 GroupBox 伸展高度,为什么是您的VerticalAlignment Top? 切换到Stretch它应该可以工作。

于 2013-02-04T10:36:00.223 回答
0

请参考此注: WPF Groupbox 高度需要动态改变?

底线 - 将宽度和高度设置为“自动”(删除它们拥有的值),如果您也需要将垂直对齐/水平设置为“拉伸”

于 2014-06-17T20:44:03.473 回答