灵活的仅XAML布局.是否有可能? [英] Flexible XAML-only layout. Is it possible?

查看:65
本文介绍了灵活的仅XAML布局.是否有可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建可调整大小的窗口,该窗口最初将自动调整为其内容. 如果窗口的大小达到一定限制,则会禁用自动调整大小,并且会修剪增长的控件或将其显示为滚动条. 当用户调整窗口大小时,也必须关闭自动调整大小".

I want to create resizable window wich will initially autosize to its content. If the size of the window reaches some limits autosizing is disabled and growing controls are either clipped or shown with scrollbars. Autosizing also must be off when user resizes the window.

真正的任务是使用文本控件创建方便的可调整大小的对话框窗口. 当它包含的文本行不多且不多时,可以合理地自动调整对话框的大小.文本数量增加,对话框变大.确保它必须有一些尺寸限制.

The real task is to create convinient resizable dialog window with text control. When it contains not much and not few text lines it is reasonable to initially autosize the dialog. The amount of text increases and dialog becomes larger. Sure it must have some size constraints.

P.S.我认为定义布局是一项非常频繁的任务,其中在布局的度量传递过程中,上浆的指导作用有条件地从孩子到父母再返回.

P.S. I think it's quite a frequent task to define the layout where the guiding role of the sizing during measure pass of the layout conditionaly swithces from children to parent and back.

分享您的想法或现有解决方案.可能是我缺少了一些东西. 谢谢.

Share you ideas or existing solutions. May be I'm missing something. Thank you.

更新1

让我解释一下算法:

1)显示了一个窗口(假设所有数据/内容都已设置).

1) Window is shown (let's imagine all data/content is already set).

2)调整其大小,就好像窗口的属性是:

2) Its size is adjusted as if window's properties were:

MaxHeight = ...

MaxHeight = ...

MaxWidth = ...

MaxWidth = ...

SizeToContent ="WidthAndHeight"

SizeToContent = "WidthAndHeight"

3)用户尝试调整窗口大小.而且他可以做到.内部控件会相应地更改其大小.

3) User tries to resize the window. And he can do it. Inner controls change accordingly their size.

此行为等效于设置的属性:

This behavior is equivalent to the properties set:

MaxWidth ="{x:Ststic Double.PositiveInfinity}"

MaxWidth= "{x:Ststic Double.PositiveInfinity}"

MaxHeight ="{x:Ststic Double.PositiveInfinity}"

MaxHeight = "{x:Ststic Double.PositiveInfinity}"

SizeToContent =手动"

SizeToContent = "Manual"

ResizeMode ="CanResizeWithGrip"

ResizeMode = "CanResizeWithGrip"

推荐答案

是的,您只能通过XAML使用动画/触发器来做到这一点,但这有点棘手. 只需挂接到TextBlock Loaded事件(仅xaml)并更改SizeToContent = manual&&使用动画在EventTrigger内设置MaxWidth& MaxHeight = PosInfinity.

Yes, you can do it with XAML only using animations/triggers but it's a little tricky. Just hook into TextBlock Loaded event(xaml only) and change SizeToContent=manual && MaxWidth&MaxHeight=PosInfinity inside EventTrigger using animation.

这篇关于灵活的仅XAML布局.是否有可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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