DependencyProperty.UnsetValue appears when using IMultiValueConverter

I created a simple converter to concatenate the text of four text fields in my WPF application.

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 am using 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 debugging, this error appears in the CodeBoatTxt: "DependecyProperty.UnsetValue" text box.

What's wrong with my converter?

+2


source to share


1 answer


DependencyProperty.UnsetValue

passed to the transformer when a is Binding

valid but not yet set to its value. I would check Binding

containing yours MultiBinding

in isolation and make sure they are correct.



+2


source







All Articles