1

我使用 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>

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

4

1 回答 1

1

您可以在以下TextTrimming属性的帮助下执行此操作TextBlock

<Button Margin="5,5,5,5">
    <TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"></TextBlock>
</Button>
于 2013-08-07T07:53:59.740 回答