C# 当我打开窗户时,底部的元素消失了

C# 当我打开窗户时,底部的元素消失了,c#,wpf,C#,Wpf,我正在做一个项目,我在伸展窗口方面遇到了问题。当我这样做时,stackpanel中的最后一个元素将消失。我有一个主StackPanel,里面有更多的网格和StackPanel。 我会发布一个5秒的视频来说明我的问题,如果有人需要,我也可以发布代码 这是我的密码: <Window x:Class="BookReader2017.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

我正在做一个项目,我在伸展窗口方面遇到了问题。当我这样做时,stackpanel中的最后一个元素将消失。我有一个主StackPanel,里面有更多的网格和StackPanel。 我会发布一个5秒的视频来说明我的问题,如果有人需要,我也可以发布代码

这是我的密码:

<Window x:Class="BookReader2017.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:BookReader2017"
    mc:Ignorable="d"
    Title="MainWindow" Height="800" Width="525"
    WindowStartupLocation = "CenterScreen">


<Border Padding="10" Background="#2d2d30" Margin="0,0,0,0">


    <StackPanel Name="StackMenu">


            <Grid>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="110"/>
                    <ColumnDefinition Width="10"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="3*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Image Width="100" HorizontalAlignment="Left" Source="BrImages/logo.png" Grid.Column="0" />

                <Border Grid.Column="2" >
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="25"/>
                    </Border.Effect>

                    <Button x:Name="Button1" BorderBrush="#3db1ff" BorderThickness="0 0 0 3" Margin="2 2 2 2"  Background="#007acc" Foreground="white">
                        <StackPanel>
                            <Image Source="BrImages/open.png" Width="50" Height="30"/>
                            <TextBlock Text="Open" HorizontalAlignment="Center" />
                        </StackPanel>
                    </Button>

                </Border>

                <Border Grid.Column="3">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="25"/>
                    </Border.Effect>
                    <Button x:Name="Button2" BorderBrush="#3db1ff" BorderThickness="0 0 0 3" Margin="2 2 2 2"  Background="#007acc" Foreground="white">
                        <StackPanel>
                            <Image Source="BrImages/settings.png" Width="50" Height="30"/>
                            <TextBlock Text="Settings" HorizontalAlignment="Center" />
                        </StackPanel>
                    </Button>
                </Border>

                <Border Grid.Column="4">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="25"/>
                    </Border.Effect>
                    <Button x:Name="Button3" Click="Button3_Click" BorderBrush="#3db1ff" BorderThickness="0 0 0 3" Margin="2 2 2 2" Background="#007acc" Foreground="white">
                        <StackPanel>
                            <Image Source="BrImages/fullscreen.png" Width="50" Height="30"/>
                            <TextBlock Text="Fullscreen" HorizontalAlignment="Center" />
                        </StackPanel>
                    </Button>
                </Border>

                <Border Grid.Column="5">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="25"/>
                    </Border.Effect>
                    <Button x:Name="Button4" Click="Button4_Click" BorderBrush="#3db1ff" BorderThickness="0 0 0 3" Margin="2 2 2 2"  Grid.Column="4" Background="#007acc" Foreground="white">
                        <StackPanel>
                            <Image Source="BrImages/about.png" Width="50" Height="30"/>
                            <TextBlock Text="About" HorizontalAlignment="Center" />
                        </StackPanel>
                    </Button>
                </Border>

                <Border Grid.Column="7">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="25"/>
                    </Border.Effect>
                    <Button x:Name="Button5" BorderBrush="#ff95b2" BorderThickness="0 0 0 3" Margin="2 2 2 2" Background="#b81d47" Foreground="white">
                        <StackPanel>
                            <Image Source="BrImages/exit.png" Width="50" Height="30"/>
                            <TextBlock Text="Exit" HorizontalAlignment="Center" />
                        </StackPanel>
                    </Button>
                </Border>


            </Grid>

            <Separator Background="#1e1e1e" Margin="0,10,0,10"/>


            <FlowDocumentReader Height="Auto" Margin="0 0 0 0" Foreground="white" Background="#007acc">
                <FlowDocument Background="#1e1e1e">

                </FlowDocument>
            </FlowDocumentReader>

            <TextBlock Text="BookReader 2017" TextAlignment="Center"/>

        </StackPanel>

</Border>


我想我已经明白了。我移除了主StackPanel并将其全部放置在DockPanel中,然后我只对接网格。我想这是一个很好的解决方案

你能提供代码吗?当然,每个想帮助你的人都需要添加编码,对不起:)