Frage

I made a binding using WrapPanel and ItemsControl. Ok.

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

The next thing bothering me is that I want to make buttons more intelligent. I want them to replace a couple of last chars by three dots if a string exceeds the boundary of the button content. I need such a behavior because I want to provide at least three columns on the screen.

War es hilfreich?

Lösung

You can do it as following with the help of TextTrimming property of TextBlock

<Button Margin="5,5,5,5">
    <TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"></TextBlock>
</Button>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top