Reputation: 13
Can you explain how can i put binding element and plain text at the same time in a textblock?
Text="{Binding following} Following | {Binding follower} Followers"
other side
followte.Text = rootObject.following;
followert.Text = rootObject.follower;
Upvotes: 0
Views: 52
Reputation: 89325
Windows Phone doesn't support multi-binding, so you need to use multiple <Run>
s to bind TextBlock
's Text
to multiple model properties. And you need to set StringFormat
as well to display the plain-text part :
<TextBlock>
<Run>
<Run.Text>
<Binding Path="following" StringFormat="{}{0} Following"/>
</Run.Text>
</Run>
<Run>
<Run.Text>
<Binding Path="follower" StringFormat="{} | {0} Followers"/>
</Run.Text>
</Run>
</TextBlock>
Don't set Text
property manually when you're using DataBinding
. That will override the bound value. Set the DataContext
instead :
myTextBlock.DataContext = rootObject;
Upvotes: 1