Reputation: 2280
I have an ItemsControl
in my ApplicationPage.xaml and I'm binding data to it with the following code:
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="24" Text="{Binding someNumber}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
When this is displayed, I want it to display a constant string next to someNumber
. If the list contains 5, 3, 2 as someNumber values, and if the constant string is "foo" then it should look something like this:
5 foo
3 foo
2 foo
Is there any way I can accomplish this? Thanks in advance.
Upvotes: 2
Views: 233
Reputation: 236318
Use string format:
<TextBlock Margin="24" Text="{Binding someNumber, StringFormat={}{0} foo}" />
Upvotes: 3
Reputation: 3331
If the string is fixed then maybe like this
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Stackpanel Orientation="Horizontal">
<TextBlock Margin="24" Text="{Binding someNumber}"/>
<TextBlock Margin="24" Text="Foo"/>
</Stackpanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Upvotes: 0