WF4: ActivityDesigner – How to use WPF custom control in Activity Designer

1. Define the WPF custom control.
2. Refer the Current namespace in activityDesigner
3. Refer the Custom Control from Xaml

<sap:ActivityDesigner x:Class=”WF4ActivityDesignerLibrary.ActivityDesigner.CustomControlDesigner”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
xmlns:sap=”clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation”
xmlns:sapv=”clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation”
xmlns:local =”clr-namespace:WF4ActivityDesignerLibrary” mc:Ignorable=”d” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008&#8243; xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006&#8243; d:DesignHeight=”67″ d:DesignWidth=”204″>

Note: you can fire the events associated with the Custom Control from the Workflow Custom Activity.

 

Update

If you are re-building the solution using Visual Studio 2013, modify the solution with following changes.

Replace the following code inside the CustomActivityDesigner.xaml; remove the Data Trigger from the Activity Style

<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>

with

<sap:ActivityDesigner.Style>

<Style TargetType=”{x:Type sap:ActivityDesigner}”>

<Setter Property=”Template” Value=”{StaticResource CustomTemplate}”/>

</Style>

</sap:ActivityDesigner.Style>

Advertisements

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in ActivityDesigner, WF, WF4. Bookmark the permalink.

10 Responses to WF4: ActivityDesigner – How to use WPF custom control in Activity Designer

  1. Hratch says:

    Hi, You posted this article with the code in 2010, but I opened it lately in Visual Studio 2013, using .net 4.5.1, and I got an error upon dragging the activity in the workflow, and clicking on it once. The error is “InvalidOperationException. The specified Visual is not an ancestor of this Visual..” However, if I close the workflow and open again in Visual studio, the error goes away

  2. Hratch says:

    Can I send u a screen shot ?? I may be doing something wrong ?

  3. Hratch says:

    Hi,
    It works.. I’m not getting the error anymore. Thanks a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s