2017-10-04 43 views
0

我已經從存儲庫中籤出了一個XAML應用程序,並且正在嘗試構建它。我得到的錯誤:InverseBooleanConverter丟失

The tag 'InverseBooleanConverter' does not exist in XML namespace 'clr- ... 

我沒有與通用的形式應用的經驗,卻發現InverseBooleanConverter是關係到FreshEssentials包。我已經爲我當前的項目安裝了這個軟件包,但這並沒有解決問題。 XAML的

內容:

<UserControl.Resources> 
    <ResourceDictionary> 
     <converters:InverseBooleanConverter x:Key="InverseBooleanConverter" /> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/Tools.TestTool.Common;component/Styles/ModulesStyle.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</UserControl.Resources> 

我怎樣才能避免這個錯誤?

+0

你有添加? –

+0

或xmlns:fe =「clr-namespace:FreshEssentials;程序集= FreshEssentials」 – BugFinder

+0

查看轉換器命名空間的xmlns定義。這會告訴你它在哪裏尋找那個轉換器。由於轉換器的組裝尚未建立,通常會出現這些錯誤。查看解決方案的構建順序,並嘗試重建違規組件。 – CKII

回答

0

此錯誤意味着,無論URL您已在XAML指定爲converters(如:xmlns:converters="clr-namespace:MeLibrary.Converters)不包含名爲InverseBooleanConverterIValueConverter派生類。

要解決這個問題,只需指出您的converters以糾正項目中的命名空間。如果您沒有任何InverseBooleanConverter類,請創建一個並指向converters以新創建名稱空間。


例如轉換器:

public class InverseBooleanConverter : IValueConverter 
{ 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
     try 
     { 
      bool testValue = (bool)value; 
      return !testValue; // or do whatever you need with this boolean 
     } 
     catch { return true; } // or false 
    } 

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
     return Convert(value, targetType, parameter, culture); 
    } 
}