1

我将数据绑定到列表框,并将 texttrimming 属性设置为 WordEllipsis,但它似乎不起作用。文本块显示文本就像没有设置 texttrimming 属性一样。这是我的 xaml 代码。请帮忙。

           <Grid>
                <Grid.Resources>
                    <application:ViewModel x:Key="ViewModel"/>
                </Grid.Resources>
                <TextBlock Height="75" TextWrapping="Wrap" Text="Click on Settings to search for quotes (by author or by query)." VerticalAlignment="Top" TextAlignment="Center" FontSize="26.667"/>
                <ListBox Margin="0,166,0,0" Name="lstQuote" DoubleTap="lstQuote_DoubleTap" Hold="lstQuote_Hold">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <es:RegularPolygon Fill="#FFF4F4F5" Height="90" InnerRadius="0.47211" PointCount="5" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" Width="84"/>
                                <StackPanel Orientation="Vertical" Margin="0,10,0,0">
                                    <TextBlock Text="{Binding Author}" TextWrapping="Wrap" FontSize="24"/>
                                    <TextBlock Text="{Binding Quote}" TextWrapping="NoWrap" FontSize="30" TextTrimming="WordEllipsis" Width="Auto" />

                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <Button Content="Random Quote" Height="79" Margin="48,83,44,0" VerticalAlignment="Top" x:Name="quotSearch" Click="quotSearch_Click" />
            </Grid>
4

1 回答 1

3

将 TextBox Width 属性更改为固定宽度

<TextBlock Width="200" Height="75" TextWrapping="Wrap" Text="Click on Settings to search for quotes (by author or by query)." VerticalAlignment="Top" TextAlignment="Center" FontSize="26.667"/>
于 2012-04-29T07:44:07.403 回答