Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF MultiBinding - UnsetValue Issue

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?

like image 748
David Ward Avatar asked Jun 29 '10 09:06

David Ward


1 Answers

for a multibinding you need to add a fallback value if it is just blank then you can simply do:

<MultiBinding StringFormat="{}{0} {1}">
    <Binding Path="Applicant2.Forenames" FallbackValue=""/>
    <Binding Path="Applicant2.Surname" FallbackValue=""/>
</MultiBinding>
like image 86
Leom Burke Avatar answered Oct 02 '22 15:10

Leom Burke