locked
Design a custom PropertyValueEditor for a re-hosted project RRS feed

  • Question

  • Hello,

    as a part of my Workflow re-hosted project I'd like to design a custom propertyvalueeditor. First of all, any user input during run-time is just meant for being stored in the xaml file, there is no need for "execute" the workflow.

    For my workflow I am using custom activities with a custom activitydesigner. I would like the text typed in the property editor being displayed within my custom activity, without typing it directly into the activity by using a TextBox. For my custom activity I am using Ambily KK's sample.

    <sap:ActivityDesigner x:Class="HelloWorkflow.Activities.Designers.CustomActivityDesigner"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
      xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation" 
           IsEnabled="True" ExpandState="False">  
      <sap:ActivityDesigner.Resources>
        <ResourceDictionary>
          <ControlTemplate x:Key="CustomTemplate">
            <Border x:Name="border" BorderThickness="1" 
                BorderBrush="Black"
                Background="Orange" 
                CornerRadius="4" Focusable="True"
                >
              <Grid>
                <StackPanel>
                  <TextBlock Text="Activity Title" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" FontStretch="UltraCondensed" TextTrimming="CharacterEllipsis" FontWeight="Bold" />
                  <!--User input is shown here-->
                  <TextBlock Text="{Binding Userinput}"></TextBlock>
                </StackPanel>
                
                
              </Grid>
            </Border>
          </ControlTemplate>
        </ResourceDictionary>
      </sap:ActivityDesigner.Resources>
      
      <sap:ActivityDesigner.Style>
        <Style TargetType="{x:Type sap:ActivityDesigner}">
          <Style.Triggers>
            <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="false">
              <Setter Property="Template" Value="{StaticResource CustomTemplate}"/>
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </sap:ActivityDesigner.Style>
    </sap:ActivityDesigner>
    
    

    Furthermore I'm planning to make the property editor's entries be dependent from each other, e.g. just after one entry has content, the next one appears. I've heard about three different types of editors, so which would be most appropriate for my requirements? Is it necessary to design a custom editor template?

    I'm really new to the whole topic so thank you very much for any help!!

     

    Monday, July 4, 2011 8:54 AM

Answers

  • Hi,

    Have you checked this sample:
    http://msdn.microsoft.com/en-us/library/ee834515.aspx

    Regards


    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Thursday, July 21, 2011 6:48 AM
    Monday, July 11, 2011 7:00 AM
  • Hi Lyndon, 

    you can take 2 different approaches:

    1) The complex one: AttachedPropertyService is the answer. Basically you can add your properties dynamically based on the value of other properties, also providing the values for the properties themselves through a custom designer. 

    2) The simple one: Hide your properties from the standard property editor, and create your own configuration dialog where you define your flow in defining the properties. Doing this way you can customize your designer experience with your own designer, and use your WPF or Win Forms UI. 

    Chosing one or the other approach depends a lot on the time you allocated for this feature as well as the UX you want to have.

    Keep in mind that employing AttachedPropertyService is not the easiest think to develop, however it's definitely the way to go in order to inject dynamic properties on the designer/property editors.

    In order to have an idea of what means implementing AttachedPropertyService, please look at Rory's blog. He published this wonderful post regarding how to build a Generic-based activity, actually done by publishign the "T" argument, that, when changed, dynamically build the object properties of that type using the MorphHelper:

    http://www.neovolve.com/post/2010/09/30/Creating-updatable-generic-Windows-Workflow-activities.aspx

    Hope it helps,

    Cheers


    Adriano
    • Marked as answer by Andrew_Zhu Thursday, July 21, 2011 6:48 AM
    • Unmarked as answer by lyndon23 Friday, August 5, 2011 12:42 PM
    • Marked as answer by lyndon23 Friday, August 5, 2011 12:43 PM
    Tuesday, July 12, 2011 12:26 PM

All replies

  • Hi,

    Have you checked this sample:
    http://msdn.microsoft.com/en-us/library/ee834515.aspx

    Regards


    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Thursday, July 21, 2011 6:48 AM
    Monday, July 11, 2011 7:00 AM
  • Hi Lyndon, 

    you can take 2 different approaches:

    1) The complex one: AttachedPropertyService is the answer. Basically you can add your properties dynamically based on the value of other properties, also providing the values for the properties themselves through a custom designer. 

    2) The simple one: Hide your properties from the standard property editor, and create your own configuration dialog where you define your flow in defining the properties. Doing this way you can customize your designer experience with your own designer, and use your WPF or Win Forms UI. 

    Chosing one or the other approach depends a lot on the time you allocated for this feature as well as the UX you want to have.

    Keep in mind that employing AttachedPropertyService is not the easiest think to develop, however it's definitely the way to go in order to inject dynamic properties on the designer/property editors.

    In order to have an idea of what means implementing AttachedPropertyService, please look at Rory's blog. He published this wonderful post regarding how to build a Generic-based activity, actually done by publishign the "T" argument, that, when changed, dynamically build the object properties of that type using the MorphHelper:

    http://www.neovolve.com/post/2010/09/30/Creating-updatable-generic-Windows-Workflow-activities.aspx

    Hope it helps,

    Cheers


    Adriano
    • Marked as answer by Andrew_Zhu Thursday, July 21, 2011 6:48 AM
    • Unmarked as answer by lyndon23 Friday, August 5, 2011 12:42 PM
    • Marked as answer by lyndon23 Friday, August 5, 2011 12:43 PM
    Tuesday, July 12, 2011 12:26 PM
  • Hi Adriano,

    thank you for your answer. I would like to stick with the standard property editor. Because the [Browsable] attribute is just statically hiding my property, I'm looking for a solution that hides/unhides my property in design-time, for example depending on what was selected from a dropbox within the property editor.

    Another question: how can I set a property to be read-only? [ReadOnly(true)] makes the property disappear, if it does not have a set accessor it leads to an exception.
    Thank you,

    lyndon

    Friday, August 5, 2011 12:57 PM