位于底部的额外空间TextBlock(Windows Phone 8)

时间:2015-12-12 20:00:29

标签: xaml silverlight windows-phone-8 windows-phone

我将TextBlock元素放在newsfeed矩形的底部有问题。 我附上问题的图像(红色箭头指向它)。 “timeago”TextBlock底部有太多额外空间。

您可以看到只有当电影标题足够短以适合第一行时才会出现问题。 我猜这会使StackPanel缩小,因此随着时间的推移移动TextBlock更高。

我尝试将父StackPanel的MinHeight更改为更低的值甚至删除属性,但它似乎不起作用。 我猜这个问题是“内部”StackPanel包含内容明星(不可见)和“ timeago

problem with extra space under TextBlock (red arrow is pointing at it) Tv Time Windows Phone

这是我的LongListSelector的DataTemplate

<DataTemplate>
    <Grid Margin="12,2,5,4" >
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Rectangle Fill="{StaticResource PhoneAccentBrush}"
                           Opacity="0.75"
                           Margin="0,0"
                           HorizontalAlignment="Stretch"
                           VerticalAlignment="Stretch"/>

        <StackPanel Grid.Row="0" Orientation="Horizontal" 
                        Background="Transparent" 
                        Height="auto"
                        MinHeight="99"
                        Width="auto">

            <Grid HorizontalAlignment="Center" 
                          Background="#FFFFC700" 
                          Height="auto" 
                          Width="99">
                <Image Source="{Binding ImageUrl}" 
                       Height="auto" 
                       Width="auto" 
                       Stretch="UniformToFill" 
                       Margin="0" 
                       HorizontalAlignment="Center" 
                       VerticalAlignment="Stretch">
                </Image>
            </Grid>


            <StackPanel Width="311" Margin="8,-7,0,0">
                    <TextBlock Margin="10,15,15,0" Text="{Binding Content}" Style="{StaticResource NewsFeedHighlitedContent}" FontSize="24" />

                <Grid Margin="10,5,0,15" Visibility="{Binding StarsVisibility}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30" />
                        <ColumnDefinition Width="30" />
                        <ColumnDefinition Width="30" />
                        <ColumnDefinition Width="30" />
                        <ColumnDefinition Width="30" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>

                    <Image Source="{Binding StarOne}" Height="30" Margin="0,0" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="0" />
                    <Image Source="{Binding StarTwo}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="1" />
                    <Image Source="{Binding StarThree}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="2" />
                    <Image Source="{Binding StarFour}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="3" />
                    <Image Source="{Binding StarFive}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="4" />

                </Grid>

                <TextBlock Text="{Binding Time}" Margin="8,14,25,7" VerticalAlignment="Bottom" Style="{StaticResource NewsTimeAgoStyle}" />
            </StackPanel>
        </StackPanel>
    </Grid>
</DataTemplate>

“NewsTimeAgoStyle”的风格

<Style x:Key="NewsTimeAgoStyle" TargetType="TextBlock">
    <Setter Property="Foreground" Value="White" />
    <Setter Property="FontSize" Value="20"/>
    <Setter Property="FontFamily" Value="Segoe WP Light" />
    <Setter Property="Margin" Value="0,14,20,0" />
    <Setter Property="Opacity" Value="0.8" />
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="HorizontalAlignment" Value="Right" />
</Style>

有没有人知道如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

我不确定,但问题可能是因为您使用rm -f *.html 来显示标题和时间前的文字。我已将StackPanel一点改为使用DataTemplate小组。试试这个,看看这有什么不同

Grid