microsoft / xaml-designer-extensibility

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

"Suggested Actions" content is not loaded #25

Closed arivoir closed 4 years ago

arivoir commented 4 years ago

I'm trying to create "Suggested Actions" for a control, but the content of the popup doesn't appear

I created this class (It's a copy of the documentation)

    public class C1PathIconSuggestedActionProvider : SuggestedActionProvider
    {
        public static ActionToken Token_Property_IsCancel = new ActionToken(0x1001);
        public static ActionToken Token_Property_IsDefault = new ActionToken(0x1002);
        public static ActionToken Token_Last = new ActionToken(0x10FF);
        public override string Header => "Actions";
        public override string Type => "CustomControlLibrary.WpfCore.ExampleButton";
        public override void Initialize()
        {
            this.ShowNameProperty = true;
            base.Initialize();

            this.AddGroup(new ActionGroup(SuggestedActionProviderTokens.Token_Group_Common,
                new PropertyAction(SuggestedActionProviderTokens.Token_Property_Content, "Content"),
                new PropertyAction(SuggestedActionProviderTokens.Token_Property_Background, "Background"),
                new PropertyAction(SuggestedActionProviderTokens.Token_Property_IsEnabled, "IsEnabled")
                ));

            this.AddGroup(new ActionGroup(SuggestedActionProviderTokens.Token_Group_Specific,
                new PropertyAction(C1PathIconSuggestedActionProvider.Token_Property_IsCancel, "IsCancel"),
                new PropertyAction(C1PathIconSuggestedActionProvider.Token_Property_IsDefault, "IsDefault")));

        }
    }

And added this attributes

Builder.AddCustomAttributes("C1.WPF.Core.C1PathIcon", new SuggestionsAttribute());
Builder.AddCustomAttributes("C1.WPF.Core.C1PathIcon", new FeatureAttribute(typeof(C1PathIconSuggestedActionProvider)));

The icon appeared, but when open the popup there is nothing.

image

When debugging it, I see the attributes are added, but it never calls "Initialize" method.

koljaka commented 4 years ago

public override string Type => "CustomControlLibrary.WpfCore.ExampleButton";

Please change it to full type name of your control. And also PropertyAction should be added for existing properties in your control

arivoir commented 4 years ago

It worked now

    public class C1PathIconSuggestedActionProvider : SuggestedActionProvider
    {
        public static ActionToken Token_Property_Data = new ActionToken(0x1001);
        public static ActionToken Token_Property_Foreground = new ActionToken(0x1002);
        public static ActionToken Token_StrokeBrush = new ActionToken(0x10FF);
        public static ActionToken Token_StrokeThickness = new ActionToken(0x10FE);

        public override string Header => "Actions";
        public override string Type => "C1.WPF.Core.C1PathIcon";

        public override void Initialize()
        {
            this.ShowNameProperty = true;
            base.Initialize();

            this.AddGroup(new ActionGroup(SuggestedActionProviderTokens.Token_Group_Common,
                new PropertyAction(Token_Property_Data, "Data"),
                new PropertyAction(Token_Property_Foreground, "Foreground"),
                new PropertyAction(Token_StrokeBrush, "StrokeBrush"),
                new PropertyAction(Token_StrokeThickness, "StrokeThickness")
                ));
        }
    }

image

Thanks