WPF中的网格拆分器查询 [英] Gridsplitter Query in WPF

查看:85
本文介绍了WPF中的网格拆分器查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含4行的网格.

第二行有一个网格分割器

第四行有一个状态栏.我想确保,无论用户如何移动网格拆分器-状态栏

应保持固定在窗口底部.

现在发生的事情是,当用户将栅格分割器向下移动太多时,状态栏会从窗口中推出.

我该怎么做才能避免这种情况?

这是我的代码.

I have a Grid with 4 rows.

2nd row has a grid splitter

4th row has a status bar. I want to make sure that, no matter how the user moves the grid splitter - The status bar

Should remain fixed at bottom of the window.

What is happening right now is that, when user moves the gridsplitter too much downwards, the status bar is pushed out of the window.

what can I do to avoid this ?

This is my code.

<Window x:Class="WpfApplication1.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="100"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*" MinHeight="100"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>

        <GridSplitter Grid.Row="1" Height="10" HorizontalAlignment="Stretch" VerticalAlignment="Center"></GridSplitter>

        <StatusBar Grid.Row="3">
            <TextBox Text="Welcome"></TextBox>
        </StatusBar>

    </Grid>
</Window>

推荐答案

使用两个网格,其中一个带有内部网格,并且StatusBar和内部网格包含三行

Use two Grid''s one with an inner Grid and the StatusBar and the inner grid contains the three rows

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="100"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" MinHeight="100"/>
        </Grid.RowDefinitions>
 
        <GridSplitter Grid.Row="2" Height="10" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
    </Grid>

 
    <StatusBar Grid.Row="1">
        <TextBox Text="Welcome"/>
    </StatusBar>
 
</Grid>


这篇关于WPF中的网格拆分器查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆