当我拉伸窗户时,底部元素消失了



我正在从事某些项目,并且在拉伸窗口时遇到问题。当我在Stackpanel失去的最后一个元素时。我有一个主stackpanel,里面有更多的网格和stackpanels。我会发布有关我的问题的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,将所有堆放在一个码头板上,然后我只是停靠了网格。我想这是一个很好的解决方案。

最新更新