使网格拉伸到 AccordionItem 的宽度/高度

发布于 2024-08-14 04:32:31 字数 284 浏览 2 评论 0原文

我正在编写的 Silverlight 应用程序中有几个手风琴(甚至是手风琴内的手风琴!),但布局让我发疯。

例如,假设您有一个 500x500 的手风琴。如果您有 3 个 AccordionItems,则“内容”区域是 Accordion 的高度/宽度,减去每个标题的宽度/高度乘以您拥有的项目数。

如果我添加或删除一个项目,如果我想通过手动将网格设置为每个 AccordionItems 内容的结果大小,将项目停靠在每个 AccordionItem 的右侧或左侧,则必须重新开始。

有办法解决这个问题吗?

I have a couple of Accordions in a Silverlight App I'm writing (even an Accordion inside of an Accordion!) but the layout is driving me insane.

For example, suppose you have a 500x500 Accordion. If you have 3 AccordionItems, the "Content" area is whatever the height/width of the Accordion is, MINUS the width/height of each header times the number of items you have.

If I add or remove an item, I have to start over if I want to dock items to the right or left of each AccordionItem by manually setting a grid to the resulting size of each AccordionItems content.

Is there a way around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

归属感 2024-08-21 04:32:31

你想要的事情可以非常简单地完成。只需在 AccordianItem 元素上将 Horizo​​ntalContentAlignment 和 VerticalContentAlignment 设置为“Stretch”,它们的内容就会拉伸以填充任何可用空间。

显示拉伸和未拉伸内容的简单示例:

<controlsToolkit:Accordion Width="500" Height="500">
        <controlsToolkit:AccordionItem HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
            <Grid Background="Bisque">
                <TextBlock Text="I will be in a grid that fills the accordianitem"></TextBlock>
            </Grid>
        </controlsToolkit:AccordionItem>
        <controlsToolkit:AccordionItem>
            <Grid Background="Aqua">
                <TextBlock Text="My Grid will only be the size of this text"></TextBlock>
            </Grid>
        </controlsToolkit:AccordionItem>
</controlsToolkit:Accordion>

What you want can be done very simply. Just set HorizontalContentAlignment and VerticalContentAlignment to "Stretch" on the AccordianItem elements, and their contents will stretch to fill whatever the available space is.

Simple example showing stretched and unstretched content:

<controlsToolkit:Accordion Width="500" Height="500">
        <controlsToolkit:AccordionItem HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
            <Grid Background="Bisque">
                <TextBlock Text="I will be in a grid that fills the accordianitem"></TextBlock>
            </Grid>
        </controlsToolkit:AccordionItem>
        <controlsToolkit:AccordionItem>
            <Grid Background="Aqua">
                <TextBlock Text="My Grid will only be the size of this text"></TextBlock>
            </Grid>
        </controlsToolkit:AccordionItem>
</controlsToolkit:Accordion>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文