本文介绍了TextTrimming不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将数据绑定到列表框,并且将texttrimming属性设置为WordEllipsis,但它似乎不起作用.文本块显示的文本就像没有设置texttrimming属性时一样.这是我的xaml代码.请帮忙.
I have data binding to a listbox, and texttrimming property set to WordEllipsis, but it doesn't seem to work. The textblocks are showing text as if they do without the texttrimming property set. This is my xaml code. Please help.
<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>
推荐答案
将文本框宽度"属性更改为固定宽度
change TextBox Width properties to fixed 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"/>
这篇关于TextTrimming不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!