2010-10-27 88 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将其视为模块类中的嵌套类)。