如何创建到窗口客户区的XAML绑定? [英] How do I create an XAML binding to the client area of a Window?

查看:93
本文介绍了如何创建到窗口客户区的XAML绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在尝试创建一个故事板,它将调整网格的大小,直到它与当前窗口的客户区域高度相同。然而,凭借我现在所拥有的,我的网格中的文本继续运行屏幕,我唯一的结论是它正在调整到整个窗口,边框和所有的高度。我试过ActualHeight,但这也没用。有任何想法吗?提前致谢。



So, I'm trying to create a storyboard that will adjust the size of the grid until it is the same height as the client area of the current window. Yet, with what I have now, the text in my grid keeps running of the screen, and my only conclusion is that it is adjusting to the height of the full window, border and all. I tried "ActualHeight" but that didn't work either. Any ideas? Thanks in advance.

<Storyboard x:Key="slideUp">
           <DoubleAnimation Duration="0:0:0.5"
                            Storyboard.TargetProperty="Height"
                            To="{Binding ElementName=MainWindow, Path=Height}" />
</Storyboard>

推荐答案

如果网格在窗口内,你不应该做这样的技巧来拉伸它。只需将 Horizo​​ntalAlignment VerticalAlignment 设置为 Stretch 即可占用所有客户区。您可以通过将网格背景设置为某种颜色来检查它。如果看起来文本不在窗口中,那么布局可能有问题。也许你需要像 WrapPanel 这样的东西,或只是设置 TextWrapping

它会是如果你在这里发布你的窗口和截图的xaml更好。它将允许人们帮助你。
if the grid is inside window, you should not do such tricks to stretch it. Just set HorizontalAlignment and VerticalAlignment to Stretch and it will occupy all client area. You can check it by setting grid background to some color. If it looks like text is out of the window, perhaps there is something wrong with your layout. Maybe you need somwthing like WrapPanel, or just to set TextWrapping.
It would be better if you post here the xaml of your window and screenshot. It will allow people to help you.


这篇关于如何创建到窗口客户区的XAML绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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