簡體   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