designerHost uses the wrong activity designer

I have the code shown below to assign a custom designer to my custom activity. The activity type shown is the type I use as the root activity type in my workflow.

When I later look at the rootDesigner using the following code

IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;

then I can see that the RootComponent is of type SequentialWorkflowDesigner and NOT of my custom type WorkflowActivityDesigner. The constructor of WorkflowActivityDesigner is not being called.

Why does the designerHost not use my custom designer

or

How can I change the designer used for the root component

-----------------

[Designer(typeof(WorkflowActivityDesigner))]
public partial class WorkflowActivity : SequentialWorkflowActivity {

public WorkflowActivity()
{
InitializeComponent();
}

}

public class WorkflowActivityDesigner : SequentialWorkflowRootDesigner {

protected override void OnPaint(ActivityDesignerPaintEventArgs e){

e.Graphics.DrawString("test", new Font("Arial", 12), new SolidBrush(Color.Red), this.Bounds.Left, this.Bounds.Top );

}}




Answer this question

designerHost uses the wrong activity designer

  • Avi_harush

    You need to specify rootdesigner in your attribute

    [Designer(typeof(WorkflowActivityDesigner),typeof(IRootDesigner))]



  • Huckster

    Thanks. Works like a charm :-)

    However, I don't understand why. According to the docs, the second parameter of the DesignerAttribute is used to specify the base type of the designer type. As MyDesigner is derived from SequentialWorkflowRootDesigner, I assumed that the DesignerAttribute must be configured as follows:

    [Designer(typeof(MyDesigner), typeof(SequentialWorkflowRootDesigner))]

    Why does it only work, when specifying IRootDesigner as the base type



  • skurge23423

    You can see another thread about it here - http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=561358&SiteID=1

    The basic idea is that IRootDesigner is when the activity is being designed - IDesigner is used when it is being designed as a child of another activity.



  • designerHost uses the wrong activity designer