2013-08-07 42 views
1

我使用WrapPanel和ItemsControl进行了绑定。好。在WrapPanel项目的内容中替换切掉的字符

<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> 

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

回答

1

你可以做到这一点作为具有TextBlock

<Button Margin="5,5,5,5"> 
    <TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"></TextBlock> 
</Button> 
TextTrimming物业的帮助下