2010-10-27 68 views
1

對不起,F#...XAML轉換到另一個項目

我有以下類VS項目:

namespace ABCCommonSilverlight 

module ConvertersAndFormatters = 
    type FixedDecimalConverter() = 
     interface IValueConverter with 
      member this.Convert(value, targetType, parameter, culture) = 
       if value = null then 
        "N/A" :> obj 
       else 
        (decimalFormatter (value :?> Double)) :> obj 
      member this.ConvertBack(value, targetType, parameter, culture) = raise <| NotImplementedException() 

而且我引用其中有一個XAML另一個項目本項目資源文件,它看起來像這樣...

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:y="clr-namespace:ABCCommonSilverlight;assembly=ABCCommonSilverlight"> 

    <y:ConvertersAndFormatters.FixedDecimalConverter x:Key="abcFixedDecimalConverter" /> 
</ResourceDictionary> 

沒有ConvertersAndFormatters.FixedDecimalConverter前我得到:

異常「找不到類型」FixedDecimalConverter「。」

並與「ConvertersAndFormatters」。我得到:

異常「無法設置屬性元素的屬性。」

任何想法什麼是正確的方式來做到這一點?

回答

1

我想嘗試的第一件事是將FixedDecimalConverter類型移出模塊,以便它直接坐在名稱空間中。 (現在,CLI和XAML將其視爲模塊類中的嵌套類)。

相關問題