0

The following code example contains the usage of WPF StaticResource string value:

<system:String x:Key="Sensor">Sensor</system:String>
...
<TextBlock Text="{StaticResource Sensor}" TextAlignment="Center"/>

What I need is to insert a + char before the "Sensor" string. (For example: + Senser)

It is important to note that the usage of TextAlignment="Center" is necessary for me so replacing the TextBlcok with Label that uses HorizontalContentAlignmet="Center" is not an option, because my text is more than one line.

Thanks.

1 Answer 1

3

You can use StringFormat property.

<TextBlock Text="{Binding Source={StaticResource Sensor},
                          StringFormat={}+{0}}" TextAlignment="Center"/>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for such a quick and simple answer, your answer works exactly as I need!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.