Pregunta

He creado un simple convertidor para concatenar el texto de cuatro cuadros de texto en mi aplicación WPF.

Aquí es el convertidor:

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[] {  };
   }

}

en Xaml utilizo este código:

<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>

Cuando en la depuración, este error aparece en el cuadro de texto CodeBoatTxt: "DependecyProperty.UnsetValue"

Lo que está mal con mi convertidor?

¿Fue útil?

Solución

DependencyProperty.UnsetValue se introduce en el convertidor cuando un Binding es válida, pero no se han establecido aún su valor. Me gustaría comprobar los Bindings que comprende su MultiBinding de forma aislada y asegurarse de que son correctos.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top