Wpf 更换包装物项目内容中的截止字符
我使用WrapPanel和ItemsControl制作了一个绑定。嗯Wpf 更换包装物项目内容中的截止字符,wpf,wpf-controls,controltemplate,wpf-4.0,Wpf,Wpf Controls,Controltemplate,Wpf 4.0,我使用WrapPanel和ItemsControl制作了一个绑定。嗯 <ItemsControl ItemsSource="{Binding Stations, Source={StaticResource Container}}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsP
<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>
接下来困扰我的是我想让按钮更智能。如果字符串超出了按钮内容的边界,我希望他们用三个点替换最后几个字符。我需要这样的行为,因为我想在屏幕上至少提供三列。您可以在
TextBlock
<Button Margin="5,5,5,5">
<TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"></TextBlock>
</Button>
借助
TextBlock
<Button Margin="5,5,5,5">
<TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"></TextBlock>
</Button>