How can I refer to a binding converter in another namespace in Silverlight XAML?

Posted by Mike Pateras on Stack Overflow See other posts from Stack Overflow or by Mike Pateras
Published on 2010-05-18T19:53:06Z Indexed on 2010/05/18 20:10 UTC
Read the original article Hit count: 166

Filed under:
|
|
|
|

Since you apparently can't create a Silverlight DataTemplate in C#, I'm trying to create one in XAML. I have a converter that I need to refer to, that I have defined in C# in another namespace. I've tried doing this:

<UserControl.Resources>
        <DataTemplate x:Key="PriceTemplate">
            <TextBlock Text="{Binding Price, Converter={Converters:PriceConverter}}" />
        </DataTemplate>
    </UserControl.Resources>

Where Converters is an xmlns that points to the correct namespace. However, I get a compilation error that says:

Type 'Converters:PriceConverter' is used like a markup extension but does not derive from MarkupExtension.

I tried adding System.Windows.Markup.MarkupExtension as a parent to my converter, but it apparently doesn't exist in Silverlight.

How can I refer to my converter in XAML, without having to rewrite it in XAML?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about markup