如何使WPF DockPanel根据其子项的大小自动调整大小? [英] Way to make WPF DockPanel auto-resize based on its children's size?

查看:995
本文介绍了如何使WPF DockPanel根据其子项的大小自动调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我有一个DockPanel,其中包含一个工具栏和BrowserWindow.当我调整BrowserWindow的大小以适合内容时,我希望该更改传播到DockPanel中并自动调整大小.有设置吗?

Right now I have a DockPanel that contains a toolbar and BrowserWindow. When I re-size the BrowserWindow to fit content, I want that change to propagate up into the DockPanel and re-size automatically. Is there a setting for this?

所以我的应用的布局本质上是:

So the layout of my app is essentially:

-Browser Control Class

--DockPanel

----Toolbar (docked to Top)

----Browser Window Class

------Grid

--------Menu

--------Embedded Browser

基本上,我希望在浏览器窗口类上设置的大小能够自动调整DockPanel的大小.

Basically I want the size that I set on my Browser Window Class to automatically re-size the DockPanel.

在将大小应用于浏览器窗口之前:

Before applying size to Browser Window:

在对浏览器窗口应用大小后(我想摆脱嵌入式浏览器周围的多余空间):

After applying size to Browser Window (I want to get rid of that extra space surrounding the embedded browser):

推荐答案

DockPanel具有

DockPanel has a LastChildFill property that you can use. Try to play with it a little. Remember that BrowserWindow needs to be the last child in DockPanel.

我认为您还必须更改网格中的某些内容.应通过LastChildFill属性进行设置.至少您在正确的轨道上.

I think you will also have to change something in your Grid. By LastChildFill property should be set. You are on right track at least.

这篇关于如何使WPF DockPanel根据其子项的大小自动调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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