XAML绑定标签内容中的多个属性

时间:2016-08-19 08:06:03

标签: c# wpf xaml binding

我有两个属性,Related_Id和PageNumber。我想将这两个值绑定到一个标签。

XAML代码

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

当前输出: Related_Id

所需的输出: Related_Id / PageNumber

任何人都可以帮我找到解决方案..

谢谢..

2 个答案:

答案 0 :(得分:-1)

试试这个:

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

答案 1 :(得分:-1)

这是您正在寻找的代码:

public class Test {
    private String lastName;

    public Test() {
        lastName = "Doe";
    }
}