[英]Binding in windows phone 8
您能解释一下如何将绑定元素和纯文本同时放入文本块吗?
Text="{Binding following} Following | {Binding follower} Followers"
另一边
followte.Text = rootObject.following;
followert.Text = rootObject.follower;
Windows Phone不支持多重绑定,因此您需要使用多个<Run>
来将TextBlock
的Text
绑定到多个模型属性。 并且您还需要设置StringFormat
来显示纯文本部分:
<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>
使用DataBinding
时不要手动设置Text
属性。 这将覆盖绑定值。 改为设置DataContext
:
myTextBlock.DataContext = rootObject;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.