microsoft / xaml-designer-extensibility

Extensibility sample code for the Visual Studio XAML Designer
MIT License
67 stars 29 forks source link

Setting a property at design-time initializer that has a TypeConverter breaks the designer layout. #19

Open arivoir opened 4 years ago

arivoir commented 4 years ago

I have one WPF5 control named C1PolygonIcon icon that has a property "Points" of the type Point[]

        /// <summary>
        /// Gets the points that describe the shape.
        /// </summary>
        [TypeConverter(typeof(PointArrayTypeConverter))]
        public Point[] Points
        {
            get
            {
                return (Point[])GetValue(PointsProperty);
            }
            set
            {
                SetValue(PointsProperty, value);
            }
        }

In the DefaultInitializer of this class I'm setting this property

    class C1PolygonIconInitializer : DefaultInitializer
    {
        public override void InitializeDefaults(ModelItem icon, EditingContext context)
        {
            base.InitializeDefaults(icon, context);
            icon.Properties["Points"].SetValue("1502.13,0 1502.13,97.586 1658.97,97.586 1354.679,894.543 1160.577,894.543 1160.577,992.129 1615.981,992.129 1615.981,894.543 1459.14,894.543 1763.431,97.586 1957.534,97.586 1957.534,0");
        }
    }

When dropping the control from the toolbox the layout of the designer gets broken, despite the generated code is correct, and after rebuilding the project the designer shows the control correctly.

I'm assuming there is a problem with the TypeConverter. because I've only had the problem with this property.