[英]Cannot get MultiBinding to work
I have the following code in my test project: 我的测试项目中包含以下代码:
<StackPanel>
<TextBlock Height="50" Text="{Binding First}" />
<TextBlock Height="50" Text="{Binding Last}" />
<TextBlock Height="50" >
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} + {1}}">
<Binding Path="First" />
<Binding Path="Last" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
First and Last are string properties: First和Last是字符串属性:
public string First { get; set; }
public string Last { get; set; }
public MainWindowViewModel()
{
First = "First";
Last = "Last";
}
The first two TextBlocks with the single binding work as expected, but the one with the Multibinding doesn't. 具有单个绑定的前两个TextBlocks可以正常工作,但是具有Multibinding的一个不起作用。 If possible, I want to avoid using a converter What's wrong with my code?
如果可能,我要避免使用转换器。我的代码出了什么问题?
MultiBinding works from NET .NET 3.5 SP1 NET.NET 3.5 SP1中的MultiBinding
And you got the typo, remove last bracket "}" in String-Format 然后输入错误,删除字符串格式的最后一个括号“}”
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} + {1}">
<Binding Path="First" />
<Binding Path="Last" />
</MultiBinding>
</TextBlock.Text>
Please let know if solution works for you 请告知解决方案是否适合您
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.