1

C# has a function String.Format(string, arguments[]) which works like the following.

String.Format("here's my argument {0}", 1337)

This would return the string "here's my argument 1337". With the TextBlock object I'm having trouble getting functionality like this. I would like to do something like

<TextBlock Text=String.Format("here's my argument {0}", {Binding Argument})/>

Where it's taking a binding as an input but I can't seem to find any way to do this with a single TextBlock. Is there a similar object type which could handle this or is there some way to pull this off with text blocks?

2
  • 1
    isn't this similar to stackoverflow.com/questions/19278515/… this question? Commented Nov 9, 2014 at 4:25
  • How many parameters you want to use in the format string? Commented Nov 9, 2014 at 6:40

1 Answer 1

4

You can use StringFormat for that

<TextBlock Text="{Binding Argument, StringFormat=here\'s my argument {0}}"/>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.