Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear whitespace from end of string in WPF/XAML

I have an MVVM application that uses a listbox which is populated with images. The image string always comes from an object that I can't modify because it's generated using an edmx model.

To cut a story shory, I need to put into the following xaml a way to trim the whitespace put onto the end of the image path by SQL from the string.

<ListBox ItemsSource="{Binding AllImages}" x:Name="listBox1" Width="300" Margin="10,10,0,10">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <Image Grid.Column="0" Source="{Binding imagePath}" Height="100" Width="100" />
                <TextBlock Grid.Column="1" Text="{Binding imageId}" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Is this possible?

like image 515
Tom Avatar asked Jan 10 '12 18:01

Tom


1 Answers

Use a value converter in the binding which does the trimming for you.

like image 154
H.B. Avatar answered Sep 19 '22 18:09

H.B.