locked
UITypeEditor equivalent for PropertyInspector of WF 4.0 designer? RRS feed

  • Question

  • Does the PropertyInspetor control in the new WF editor support functionality similar to a UITypeEditor in the traditional property grid?  We have quite a few custom activities in our 3.x implementation which have properties that use custom controls to look up records from the DB and let the user select from them in the rehosted designer.  We'll need to be able to do that in 4.0 as well.

    What I'd really like to do in my activities is exactly what the Invoke Method activity does with it's "TargetType" property.  How can I do this with my custom activities?

    Thanks,
    Howard

    Monday, June 1, 2009 10:49 PM

Answers

  • What assembly does your IRegisterMetdata type live in? 

    We search for foo.Design.dll, it needs to be deployed in the same directory as the foo.dll, and we should be able to find it. 

    As roman mentions below, you can also put the attribute directly on the property as well. 
    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Wednesday, June 3, 2009 11:01 PM

All replies

  • Howard,

    - The Type property is automatically registered in the MetadataStore with a TypePropertyEditor, therefore your custom activity doesn't require any additional decoration, see the following code snippet (from Reflector):

    static WorkflowDesigner()
    {
        InitializePropertyInspectorMetadata();
        new DesignerMetadata().Register();
    }


    and the following code snippet shows implementation of the System.Activities.Design.TypePropertyEditor:

    internal sealed class TypePropertyEditor : PropertyValueEditor
    {
        // Methods
        public TypePropertyEditor()
        {
            base.InlineEditorTemplate = (DataTemplate) EditorResources.GetResources()["TypeBrowser_InlineEditorTemplate"];
        }
    }





    Thanks

    Roman

     


    Roman Kiss, MVP Connected System Developer
    Tuesday, June 2, 2009 1:36 AM
  • Howard, what behavior of the InvokeMethod designer are you looking to have in your code?  Is it about hooking up and extended or dialog editor from the property grid, or something a little more?

    Thanks,

    matt
    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Tuesday, June 2, 2009 7:54 AM
  • Hi Matt,

    What I really want to be able to do is to hook up a custom control in the property grid for a property on my custom activity.  For example, let's say my activity has an int property which stores the primary key of a particular user.  I don't want the person doing the workflow design to have to figure out what the primary key is or to write a code expression that looks it up.   I'd like them to have a nice control that opens a list or a pop up window (in roughly the same way as the UITypeEditors work), so they can select from a readable list.

    In the 3.x world we used a a UITypeEditor to allow the user to pop up a user friendly selection UI and then a TypeConverter to display the value using a text label for the selected item.  I'm wondering if there is an equivalent in the 4.0 designer.

    As for the the InvokeMethod activity, I was really just using the TargetType property as an example.  I like how it says "click to browse..." and when I hover over it, it turns into a selection control.  In most of our cases, the underlying property type will be an int which represents a primary key, but clearly we want end users doing something a little more user friendly than working with primary keys.

    Thanks,
    Howard
    Tuesday, June 2, 2009 4:40 PM
  • Right, so Roman is right pointing you to the PropertyValueEditor.  These types are very similar to the Cider (WPF ) property grid extensibility types.  A little browsing through reflector + the docs should help out here, and we'll be getting a sample around this the next time we drop some samples (and I'll probably do a blog post).

    Basically, you can register for eitehr a type, or a specific property of a class, a PropertyValueEditor (either a propertyValueEditor, a DialogPropertyValueEditor or an ExtendedPropertyValueEditor).

    Now, the DialogPropertyValueEditor is probably what you are looking for in order to "raise" a dialog, and this can be done either through the DialogTemplate, or by specifically coding the ShowDialog method, which is what we've done in most cases.

    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Tuesday, June 2, 2009 6:16 PM
  • I think I'm generally on the right track, however, I can't get the designer to find and call my class which implements IRegisterMetadata, and hence am having trouble getting my DialogPropertyValueEditor into the MetadataStore.  Looking through reflector, the static WorkflowDesigner constructor calls one version of DesignerMetadata explicitly, which does some of the basic registration.  However, it looks like there's another DesignerMetadata class in System.Activities.Core.Design which I can't find an explicit call to, so I'm assuming the designer is finding it via reflection (meaning that it should also somehow find my class via reflection).

    Anyhow, I've followed some of the WFP examples (ie.  creating a project for my assembly and a separate assembly with the IRegisterMetadata implementation which ends with *.Design.dll, putting them in the same output location, etc), and still no luck getting the designer to discover my implementation of IRegisterMetadata.  My test is all happening in Visual Studio (not a rehosted designer) with one solution with three projects.  One with a seqential WF, one with a custom activity, and one with my IRegisterMetadata implementation and my DialogPropertyValueEditor.  I've hooked up a second instance of VS as a debugger, so I know my IRegisterMetadata class is never being called.

    If you have any quick suggestions I could try, that would be great.  Otherwise, as long as I know it's possible, I'm content waiting for some code samples and a blog.  I'm a bit of a WPF novice, so it's also quite possible I'm doing something ground-breakingly stupid :)

    Thanks,
    Howard
    Tuesday, June 2, 2009 10:17 PM
  • Howard,

    - you can attribute your custom activity direct with [Designer(typeof(yourCustomDesigner))] and also your properties can be attributed. The following code snippet shows an example for collection property:

    [EditorBrowsable]
    [Editor(typeof(System.Activities.Design.ArgumentCollectionPropertyEditor), typeof(System.Activities.Design.PropertyEditing.PropertyValueEditor))]
     public Collection<Argument> Parameters
     {
         get
         {
             if (this.parameters == null)
             {
                 this.parameters = new WorkflowElement.DesignTimeAwareCollection<Argument>(this);
             }
             return this.parameters;
         }
     }
     private Collection<Argument> parameters;

    Thanks
    Roman
    • Edited by Roman Kiss Tuesday, June 2, 2009 11:38 PM
    Tuesday, June 2, 2009 11:26 PM
  • What assembly does your IRegisterMetdata type live in? 

    We search for foo.Design.dll, it needs to be deployed in the same directory as the foo.dll, and we should be able to find it. 

    As roman mentions below, you can also put the attribute directly on the property as well. 
    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Wednesday, June 3, 2009 11:01 PM
  • Hello

    If we use attributes would this not break the general design pattern. If the activities dll references the designer dll then when you deploy your custom activities you will be forced to deploy your designers as well. If you use any third party controls in your designers this will have a knock on effect. Im thinking specifically of a service scenario where you do not want to deploy UI controls into a service. 

    The metadata/attribute table approach breaks the dependancy and neatly provides the link at design time. SSIS has a similar pattern for its tasks-designers so that designers do not need to be deployed to the runtime directory (however they use wrapper classes, this design pattern is better).

    T

    Friday, June 11, 2010 8:24 AM