Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding to two values

Tags:

c#

binding

wpf

xaml

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 bind as Content={Binding Firstname} for one and Content={Binding Lastname} for another. But I want a single label to display both. Is it possible?

like image 829
developer Avatar asked Apr 01 '10 14:04

developer


1 Answers

You can do something like this

<TextBlock>
    <TextBlock.Text>
        <MultiBinding StringFormat="{}{0}, {1}">
            <Binding Path="firstName" />
            <Binding Path="lastName"/>
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>
like image 72
Chris Avatar answered Sep 28 '22 01:09

Chris