【问题标题】:Replacing cut off chars within content of WrapPanel item替换 WrapPanel 项目内容中的截断字符
【发布时间】:2013-08-07 06:05:07
【问题描述】:

我使用 WrapPanel 和 ItemsControl 进行了绑定。好的。

 <ItemsControl
    ItemsSource="{Binding Stations, Source={StaticResource Container}}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate DataType="{x:Type sys:String}">
            <Button
                Margin="5,5,5,5"
                Content="{Binding}"/>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

接下来困扰我的是我想让按钮更智能。如果字符串超出按钮内容的边界,我希望他们用三个点替换最后几个字符。我需要这样的行为,因为我想在屏幕上提供至少三列。

【问题讨论】:

    标签: wpf wpf-controls controltemplate wpf-4.0


    【解决方案1】:

    您可以在TextBlockTextTrimming 属性的帮助下执行以下操作

    <Button Margin="5,5,5,5">
        <TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"></TextBlock>
    </Button>
    

    【讨论】:

      猜你喜欢
      • 2014-12-04
      • 2015-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多