JayJay
JayJay

Reputation: 1068

DependencyProperty.UnsetValue appears when using a IMultiValueConverter

I created a simple Converter to concatenate the text of four TextBoxes in my WPF app.

Here is the Converter:

public class FourString:IMultiValueConverter
{
     public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
   {

       return string.Format("{0}{1}{2}{3}", values[0], values[1], values[2], values[3]);

   }
   public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
   {


       return new object[] {  };
   }

}

in Xaml I use this code:

<local:FourString x:Key="converter"/>


  <TextBox  Grid.ColumnSpan="4"  Margin="95,7.5,71.25,3.75" Name="CodeBoatTxt" >
                            <TextBox.Text>
                                <MultiBinding Converter="{StaticResource converter}" >
                                    <Binding ElementName="CountryStringaTxt" Path="Text" />
                                    <Binding ElementName="CityStringaTxt" Path="Text" />
                                    <Binding ElementName="ServiceStringaTxt" Path="Text" />
                                    <Binding ElementName="DurationStringaTxt" Path="Text" />

                                </MultiBinding>
                            </TextBox.Text>
                        </TextBox>

When in debug, this error appears in the CodeBoatTxt textbox: "DependecyProperty.UnsetValue".

What is wrong with my converter?

Upvotes: 2

Views: 2528

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178770

DependencyProperty.UnsetValue is passed into the converter when a Binding is valid, but does not have its value set yet. I would check the Bindings comprising your MultiBinding in isolation and ensure they are correct.

Upvotes: 2

Related Questions