字符串开头的文本修剪

时间:2011-06-28 14:25:56

标签: wpf silverlight

我在WPF中有一个应用程序,我希望在我的文本框中只看到字符串的结尾。

enter image description here

XAML:

  <Grid Height="109" Width="126">
    <Grid.RowDefinitions>
        <RowDefinition Height="166*" />
        <RowDefinition Height="145*" />
    </Grid.RowDefinitions>
    <TextBlock Text="10000004" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Width="40" Background="LightBlue"/>
    <TextBlock Text="10000005" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Width="40" Grid.Row="1" Background="LightGreen"/>
</Grid>

2 个答案:

答案 0 :(得分:1)

As you probably have seen on MSDN,您需要使用自己的TextTrimmingProperty依赖项属性创建/扩展。

Look at this扩展TextBlock,以便您可以创建自己的TextTrimmingProperty以使其工作方式不同。

答案 1 :(得分:0)

int Len = 4; //put this equcal to how many digits you need from last...
//path is the actual string 
string endText = path.Substring(path.Length - Len, path.Length)