为 Silverlight Toolkit AccordionItem 设置 MaxHeight 时出现问题
我正在尝试设置一个包含三个项目的手风琴。前两个扩展至预定义的高度,第三个扩展至填充所有剩余空间;我以为这很容易。
这是我想做的事情的虚拟版本。手风琴本身有红色背景,每个项目都有自己的颜色。前两个项目适当扩展至其大小,但如果项目 1 或 2 打开,则项目 3 不再扩展以填充所有剩余空间,但要么尺寸太小,留下一大块红色,要么太大,射出屏幕底部,遮盖了应该仍然存在的细小的红色条子。
这是一个错误吗?
我尝试通过使用两个手风琴来解决这个问题,一个具有最大高度的两个项目,第二个手风琴将扩展以填充所有剩余高度,但我永远无法设法使布局正确,因为我猜这是显而易见的各位 Silverlight 专家。
我有什么办法可以做到这一点吗?
这是完整的代码 - 另外,请注意,我尝试使用 Height 属性而不是 MaxHeight,但这只会导致 AccordionItem 始终 为该高度,无论它是否展开。
<UserControl x:Class="SilverlightApplication8.accordianDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="400"
xmlns:sdk2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit">
<Grid x:Name="LayoutRoot" Background="White">
<sdk2:Accordion SelectionMode="ZeroOrMore" Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<sdk2:AccordionItem Header="Item 1" MaxHeight="150" Background="LightGoldenrodYellow">
Hello World Row 1
</sdk2:AccordionItem>
<sdk2:AccordionItem Header="Item 2" MaxHeight="150" Background="LightGray">
Hello World Row 2
</sdk2:AccordionItem>
<sdk2:AccordionItem Header="Item 3" Background="LightBlue">
Hello World Row 3
</sdk2:AccordionItem>
</sdk2:Accordion>
</Grid>
</UserControl>
I'm trying to set up an Accordion that has three items. The first two expand to pre-defined heights, and the third expands to fill all remaining space; I thought this would be easy.
Here's a dummy version of what I'm trying to do. The accordion itself has a red background, and each of the items has its own color. The first two items expand appropriately to their size, but if either item 1 or 2 is open, item 3 no longer expands to fill all remaining space, but either sizes too small, leaving a big chunk of red, or too big, shooting off the bottom of the screen, eclipsing the tiny sliver of red that should still be present.
Is this a bug?
I tried working around this by using two accordions, one with the two items with max heights, and a second accordion that would expand to fill all remaining height, but I could never manage to get the layout right, as I'm guessing is obvious to you Silverlight experts.
Is there any way I can accomplish this?
Here's the complete code - also, note that I tried using the Height attribute instead of MaxHeight, but that just caused the accordionItem to always be that height, regardless of whether it was expanded.
<UserControl x:Class="SilverlightApplication8.accordianDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="400"
xmlns:sdk2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit">
<Grid x:Name="LayoutRoot" Background="White">
<sdk2:Accordion SelectionMode="ZeroOrMore" Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<sdk2:AccordionItem Header="Item 1" MaxHeight="150" Background="LightGoldenrodYellow">
Hello World Row 1
</sdk2:AccordionItem>
<sdk2:AccordionItem Header="Item 2" MaxHeight="150" Background="LightGray">
Hello World Row 2
</sdk2:AccordionItem>
<sdk2:AccordionItem Header="Item 3" Background="LightBlue">
Hello World Row 3
</sdk2:AccordionItem>
</sdk2:Accordion>
</Grid>
</UserControl>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试设置内容的 MaxHeight。现在您的内容是
string
尝试将其设为ContentControl
Try setting the MaxHeight on the Content. For now you have content as a
string
try making it aContentControl