silverlight – ListBox之后的按钮

silverlight – ListBox之后的按钮,第1张

概述我需要向ListBox显示动态内容(所以我不知道它的高度)和下面的Button.因此用户应该能够将ListBox滚动到结束并查看按钮. 在Android中,我会使用RelativeLayout和以下属性作为按钮或其他解决方案,但在WP中我不知道该怎么做. 我曾经尝试过的: 1)全部放入StackPanel <StackPanel> <ListBox /> <Button /></ 我需要向ListBox显示动态内容(所以我不知道它的高度)和下面的button.因此用户应该能够将ListBox滚动到结束并查看按钮.

在Android中,我会使用relativeLayout和以下属性作为按钮或其他解决方案,但在WP中我不知道该怎么做.

我曾经尝试过的:

1)全部放入StackPanel

<StackPanel>    <ListBox />    <button /></StackPanel>

这不起作用,因为StackPanel阻止了ListBox滚动.

2)好的,让我们把ListBox放在GrID中

<StackPanel>    <GrID>        <ListBox />    </GrID>    <button /></StackPanel>

什么都没发生.

3)全部放入网格并使用GrID.Row不起作用.

4)让我们全部放入网格并动态设置button的边距

<GrID>    <ListBox />    <button /></GrID>

好的,这是有效的,但这不是好的解决方案,因为我需要每次都处理ListBoxpopulating并重置按钮的边距.坏坏.

附:另外,我可以将按钮作为ListBox项目(不错,但不是很好:)

请帮帮我…

解决方法 如果我理解正确,你需要一个像这样定义的简单网格:

<GrID>    <GrID.RowDeFinitions>        <RowDeFinition Height="*" />        <RowDeFinition Height="auto" />    </GrID.RowDeFinitions>    <ListBox />    <button GrID.Row="1" Height="80"/></GrID>

通过将行的高度设置为“星形”并将第一行设置为“自动”,ListBox将填充剩余空间,而“按钮”仅为80(您可以将其更改为您喜欢的任何内容). ListBox会自动放入零行,因为如果未明确设置,则为默认值.

如果您不希望按钮固定在页面上但使用ListBox滚动,则可以编辑ListBox模板,如下所示:

<Style x:Key="ListBoxWithbuttonStyle" targettype="ListBox">    <Setter Property="Background" Value="transparent"/>    <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>    <Setter Property="ScrollVIEwer.HorizontalScrollbarVisibility" Value="Disabled"/>    <Setter Property="ScrollVIEwer.VerticalScrollbarVisibility" Value="auto"/>    <Setter Property="borderThickness" Value="0"/>    <Setter Property="borderBrush" Value="transparent"/>    <Setter Property="padding" Value="0"/>    <Setter Property="Template">        <Setter.Value>            <ControlTemplate targettype="ListBox">                <ScrollVIEwer x:name="ScrollVIEwer" borderBrush="{TemplateBinding borderBrush}" borderThickness="{TemplateBinding borderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" padding="{TemplateBinding padding}">                    <GrID>                        <GrID.RowDeFinitions>                            <RowDeFinition Height="*"/>                            <RowDeFinition Height="auto"/>                        </GrID.RowDeFinitions>                        <ItemsPresenter/>                        <button Content="touch me" Height="80" GrID.Row="1"/>                    </GrID>                </ScrollVIEwer>            </ControlTemplate>        </Setter.Value>    </Setter></Style>

然后应用于ListBox:

<GrID x:name="ContentPanel" GrID.Row="1" margin="12,12,0">    <ListBox Style="{StaticResource ListBoxWithbuttonStyle}">    </ListBox></GrID>
总结

以上是内存溢出为你收集整理的silverlight – ListBox之后的按钮全部内容,希望文章能够帮你解决silverlight – ListBox之后的按钮所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1006775.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存