WPF MultiBinding - UnsetValue 问题
我有一个文本块。当其文本绑定为:
<Binding Path="Applicant2.Surname"/>
它工作正常,但是我想包含名字,因此将绑定更改为:
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Applicant2.Forenames"/>
<Binding Path="Applicant2.Surname"/>
</MultiBinding>
这将显示 {DependencyProperty.UnsetValue} {DependencyProperty.UnsetValue} 直到第一次设置该值。
我怎样才能阻止这个?为什么我在第一个简单绑定时没有遇到问题?
I have a TextBlock. When its Text is bound as:
<Binding Path="Applicant2.Surname"/>
It works fine, however I want to include the Forenames so changed the binding to:
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Applicant2.Forenames"/>
<Binding Path="Applicant2.Surname"/>
</MultiBinding>
This displays {DependencyProperty.UnsetValue} {DependencyProperty.UnsetValue} until the value is set the first time.
How can I stop this? Why do I not get the problem with the first simple binding?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于多重绑定,您需要添加一个后备值,如果它只是空白,那么您可以简单地执行以下操作:
for a multibinding you need to add a fallback value if it is just blank then you can simply do:
对于多重绑定,我使用了下面的代码并为我工作:
下面是它的属性:
For multibinding, I used below code and worked for me :
Below is the property of it :