Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

binding to the ToString() method in a DataTemplate

Is there any easy way to bind to the ToString() method in a DataTemplate? I would expect the Text property of a TextBlock to use ToString() by default for its Text property, but that does not happen. So any easy way to do this:

<DataTemplate x:Key="myTemplate">     <TextBlock Text="{Binding ToString()}"/> <DataTemplate> 
like image 791
user1151923 Avatar asked Nov 29 '12 15:11

user1151923


1 Answers

You can use Text="{Binding}". The ToString() method is invoked implicitly.

like image 130
amnezjak Avatar answered Sep 20 '22 23:09

amnezjak