2009-08-25 36 views
2

我創建了一個簡單的Converter來連接我的WPF應用程序中的四個TextBoxes的文本。使用IMultiValueConverter時出現DependencyProperty.UnsetValue

這裏是轉換器:

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

} 

在XAML我用這個代碼:

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

當調試,出現在CodeBoatTxt文本框這個錯誤: 「DependecyProperty.UnsetValue」。

我的轉換器有什麼問題?

回答

2

DependencyProperty.UnsetValueBinding有效但尚未設置其值時傳遞到轉換器。我會單獨檢查包含您的MultiBindingBinding,並確保它們是正確的。

+0

HI Kent, 你有權利檢查我的代碼,發現我的分心錯誤。 謝謝。 乾杯 – JayJay 2009-08-25 09:38:00

相關問題