我为没有得到这个而感到难过。
但是,尽管我读了几篇关于测量pass和排列pass的文章并编写了几个小程序,但我仍然很难做到这一点。
对我来说,任何用户控件都将具有“最小尺寸”(之后唯一可能的解决方案是将其作为整个位图缩小或添加滚动条)是有意义的。它还可以使用任何额外的屏幕空间。
椭圆没有最小尺寸,并且可以折叠到尺寸零。
因此,考虑一下这个示例,
<Grid>
<StackPanel Orientation="Horizontal" Height="20">
<Ellipse Fill="Blue"/>
<Ellipse Fill="Green"/>
<Ellipse Fill="BlueViolet"/>
</StackPanel>
</Grid>
要实现以下效果,需要添加的 xaml 代码最少是多少:
- 使它们强制使用统一 40 的“最小大小”。并统一动态调整大小。
- 让它们强制使用统一的 40 的“最小尺寸”。并动态地非均匀地调整大小(以便它们可以拉伸得很宽,但尺寸永远不会低于 40/40)。
- 让它们强制达到最小高度,但拉伸到可用宽度。
- 使它们均匀拉伸以适应堆栈面板的恒定高度。
- 使 stackpanel 拉伸以填充其容器的动态高度。
谢谢。
I feel bad about not getting this.
But, although I have read several articles on measure pass and arrange pass and written several small programs, I still have a hard time with this.
It makes sense to me that any user control will have a "minimum size" (after which only possible solution would be to shrink it as a whole bitmap wise or add a scroll bar). It will also have a way to use any additional screen real estate given to it.
Ellipses have no minimum size and can collapse to size zero.
So, consider this example
<Grid>
<StackPanel Orientation="Horizontal" Height="20">
<Ellipse Fill="Blue"/>
<Ellipse Fill="Green"/>
<Ellipse Fill="BlueViolet"/>
</StackPanel>
</Grid>
what is the least amount of xaml code needed to add to achieve the following effects:
- Make them force a "minimum size" of uniform 40. And dynamically resize uniformly.
- Make them force a "minimum size" of uniform 40. And dynamically resize non-uniformly (so that the they can stretch really wide, but will never size below 40/40).
- Make them force a minimum height, but stretch to available width.
- Make them stretch uniformly fitting a constant height of the stackpanel.
- Make the stackpanel stretch to fill the dynamic height of its container.
Thank you.
发布评论
评论(1)
在大多数情况下,您可能想要使用
UniformGrid
使用一列而不是StackPanel
。要强制大小,请使用Style
设置MinHeight
和MinWidth
。如果保证一致性是“单向”的,您只需绑定宽度
到实际高度
。In most of those cases you probably want to use a
UniformGrid
with one column instead of aStackPanel
. To force sizes use aStyle
which sets theMinHeight
andMinWidth
. If the uniformity is guaranteed to be "one-way" you can just bind theWidth
to theActualHeight
.