【问题标题】:WindowsPhone 8 listboxitem has a max height limit?Windows Phone 8 列表框项目有最大高度限制?
【发布时间】:2014-01-08 08:01:01
【问题描述】:

这个问题困扰了我很久。在Page中,我用一个listbox来展示一个listdata,item datatemplate是

 <DataTemplate x:Key="PostItem">
    <Grid Width="460" Margin="0,2,0,2">
            <control:RichTextControl Segments="{Binding ListSegment, Mode=TwoWay}" FontSize="25">
                <control:RichTextControl.Template>
                    <ControlTemplate TargetType="control:RichTextControl">
                    <StackPanel Name="RootStackPanel" CacheMode="BitmapCache" Background="{StaticResource BlockBackground}"  />
                    </ControlTemplate>
                </control:RichTextControl.Template>
            </control:RichTextControl>
        </Grid>
</DataTemplate>

stackpanel RootStackPanel 是一个用户控件,我在其中添加了一个文本块。当 amont 太大时,它可以显示背景,如您所见:当项目太高而无法显示背景时。而短项目可以显示为我除外。

【问题讨论】:

    标签: c# wpf windows-phone-8 listboxitem


    【解决方案1】:

    你需要将属性水平对齐设置为这样拉伸:

    <ListBox.ItemContainerStyle> 
        <Style TargetType="ListBoxItem"> 
            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> 
        </Style> 
    </ListBox.ItemContainerStyle> 
    

    【讨论】:

    • 它不起作用。而且我跟踪非常高的列表框项,它有正确的背景颜色,但我真的没有显示为例外。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多