繁体   English   中英

在Windows Phone 8中绑定

[英]Binding in windows phone 8

您能解释一下如何将绑定元素和纯文本同时放入文本块吗?

Text="{Binding following} Following | {Binding follower} Followers" 

另一边

 followte.Text = rootObject.following;
 followert.Text = rootObject.follower;

Windows Phone不支持多重绑定,因此您需要使用多个<Run>来将TextBlockText绑定到多个模型属性。 并且您还需要设置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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM