WPF TypeConverter ConvertTo not firing

Posted by JFoulkes on Stack Overflow See other posts from Stack Overflow or by JFoulkes
Published on 2009-09-05T15:56:50Z Indexed on 2010/03/30 3:13 UTC
Read the original article Hit count: 630

Hi,

I have a dependency property in a class which I need to be converted to a string.

I have added the TypeConverty attribute on the property. The type I am converting is the .net Style class.

    [TypeConverter(typeof(BulletStyleTypeConverter))]
    public Style BulletStyle
    {
        get { return (Style)GetValue(BulletStyleProperty); }
        set { this.SetValue(BulletStyleProperty, value); }
    }

When I put the string "Rectangle" in for BulletStyle in xaml it hits the ConvertFrom method in my converter.

However, when I use XamlWriter.Save() to serialise this, the property does not appear as an attribute in the string which is produced.

I have implemented ConvertTo and put a breakpoint on, which is never hit.

I have implemented CanConvertTo and put a breakpoint on, which IS hit and returns true. So i'm stumped as to why ConvertTo never fires.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about serialization