PhilBrown
PhilBrown

Reputation: 3009

XAML converter in another project

Sorry for the F#...

I have a VS project with the following class:

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

And I've referenced this project in another project which has a XAML resources file which looks like this...

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

Without the ConvertersAndFormatters. in front of FixedDecimalConverter I get:

Exception "The type 'FixedDecimalConverter' was not found."

And with the "ConvertersAndFormatters." I get:

Exception "Cannot set properties on property elements."

Any idea what the right way to do this is?

Upvotes: 1

Views: 464

Answers (1)

Brian
Brian

Reputation: 118895

The first thing I would try is moving the FixedDecimalConverter type out of the module, so that it's sitting directly in a namespace. (Right now the CLI and XAML see it as a nested class inside the module class.)

Upvotes: 1

Related Questions