Nandu PH
Nandu PH

Reputation: 145

XAML binding multiple properties in label content

I have two properties, Related_Id and PageNumber. I want to bind these two values to a single label.

XAML code

<StackPanel>
    <sdk:Label x:Name="RelatedItemIdLabel"  
    HorizontalAlignment="Left"
    VerticalAlignment="Top"
    Content="{Binding CreateMessage.RelatedId}" />
</StackPanel>

current output: Related_Id

Desired output: Related_Id/ PageNumber

Could anyone help me to find a solution..

Thanks..

Upvotes: 1

Views: 3596

Answers (2)

ViVi
ViVi

Reputation: 4464

This is the code you're looking for :

<StackPanel>
    <sdk:Label x:Name="RelatedItemIdLabel"  
    HorizontalAlignment="Left"
    VerticalAlignment="Top">    
    <sdk:Label.Content>
        <MultiBinding StringFormat=" {0}, {1}">
            <Binding Path="{Binding CreateMessage.RelatedId}"/>
            <Binding Path="{Binding CreateMessage.PageNumber}"/>
        </MultiBinding>
    </sdk:Label.Content>    
    </sdk:Label>
</StackPanel>

Upvotes: -1

Sameed
Sameed

Reputation: 703

Try this:

 <Label x:Name="RelatedItemIdLabel"
           HorizontalAlignment="Left"
           VerticalAlignment="Top">
        <Label.Content>
            <MultiBinding StringFormat=" {0}/{1}">
                <Binding Path="" /> //insert field 1
                <Binding Path="" /> //insert field 2
            </MultiBinding>
        </Label.Content>
    </Label>

Upvotes: 2

Related Questions