tags:

views:

35

answers:

2

I have a details view window in WPF and a label may look like this.

<Label Content="{x:Static properties:Resources.Reference}" />

So that is obtains it content from my property Resource.

How can transform/format the content so it has a colon after each label item. e.g. instead of the content simply displaying Reference I want it to transform to Reference:

+1  A: 

You can use a Binding with StringFormat to format the result.

<Label Content="{Binding Source={x:Static properties:Resource.Reference}, StringFormat='{}{0}:'}"

Note that the {} before the format string is here to prevent the XAML parser from treating {0} as a markup extension, like {StaticResource} for example.

Julien Lebosquain
Thank-you for your response. For some strange reason I could not get your suggestion to work, but it did set me on the right course to a solution which was: Content="{x:Static properties:Resources.Date}" ContentStringFormat="{}{0}:"
Allan
A: 

The solution I ended up with was:

<Label Content="{x:Static properties:Resources.Reference}" ContentStringFormat="{}{0}:"/>
Allan
Strangely enough - this was one of the earlier solutions I tried and it would not work? I have since discovered that sometimes the 'wysiwyg' window does not update correctly until I do a full compile !
Allan