开发者

Binding to two values

开发者 https://www.devze.com 2022-12-25 15:01 出处:网络
Is it possible to bind a label content to two values. For eg, I want a single label whose content is displayed as below,

Is it possible to bind a label content to two values. For eg, I want a single label whose content is displayed as below, UserName= Firstname, Lastname

where Firstname and Lastname, both are values from database. If I would be using to labels I would bi开发者_Go百科nd as Content={Binding Firstname} for one and Content={Binding Lastname} for another. But I want a single label to display both. Is it possible?


You can do something like this

<TextBlock>
    <TextBlock.Text>
        <MultiBinding StringFormat="{}{0}, {1}">
            <Binding Path="firstName" />
            <Binding Path="lastName"/>
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>
0

精彩评论

暂无评论...
验证码 换一张
取 消