Silverlight 4 has introduced an useful feature to make this more easy: StringFormat.
Now you can put more informations in a single element.
The code is very simple:
<TextBlock Text="{Binding Username, StringFormat='Hello \{0\}'}" /> <TextBlock Text="{Binding Temperature, StringFormat=\{0\}°}" />
and it works also with numbers and dates:
<TextBlock Text="{Binding Value, StringFormat=\{0:n2\}}" /> <TextBlock Text="{Binding Value, StringFormat=\{0:c2\}}" /> <TextBlock Text="{Binding Date, StringFormat=f}" />
You can check more details in the Kunal's blog
Nessun commento:
Posta un commento