Reputation: 3
I'm trying to create a simple textblock control and I'm trying to insert a property from my ViewModel in the middle of the string.
E.G. "Hello, My name is XX, bla, bla." (XX is a property from my ViewModel)
<TextBlock Text="Hello, My name is {Binding SelectedUser.Name}, bla, bla." />
Is that possible?
Regards,
Adrian
Upvotes: 0
Views: 687
Reputation: 131
Similar feature has been added to WPF with .NET 3.5 sp1, but not to Slverlight
See Link: WPF 3.5 SP1 Feature: String Format
WPF Example:
<TextBlock
Text={Binding SelectedUser.Name, StringFormat=Hello, My name is: \{0\}, bla, bla.}/>
As far as Silverlight is concerned, you are stuck to either creating another property in your view model that does the concatenation for you, or creating an IValueConverter
Upvotes: 3