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”
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”
xmlns:local =”clr-namespace:WF4ActivityDesignerLibrary” mc:Ignorable=”d” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ 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>
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
I will verify the same in Visual Studio 2013 along with .NET 4.5.1 and reply with the observations
Thanks
Ambily
Thanks alot
Hi again, any luck in reproducing the error ?
I am not able to reproduce the issue.
For implementing different concepts in WF 4.5, please refer my book at
https://leanpub.com/windowsworkflowfoundation45developerguide/
Regards
Ambily
Can I send u a screen shot ?? I may be doing something wrong ?
Sure, please share the requirement; what exactly you are trying to do ? I will respond with a sample developed in VS 2013
Hi,
So, Here are the steps :
– Downloaded the source code from : http://www.dotnetfunda.com/articles/show/963/workflow-foundation-40-activity-designer
– Open the solution in Visual Studio 2013 and compiled the whole solution
– In the TestApplication Project I opened Workflow1.xaml
– From the toolbox Under “WF4ActivityDesignerLibrary.Activities” section, I dragged the activity “ActivityWithCustomLook” to the workflow
– I click on that activity once and I get the following error :
https://onedrive.live.com/redir?resid=C763FAAD0C939C3E!12074&authkey=!AFUUTuQeDLZlbSk&v=3&ithint=photo%2cpng
Note that If I click on already existing custom activities in the workflow, the error does not happen. Also, If I save the workflow after dragging the new custom activity, close the workflow, open it again, then I don’t get the error. This happens only after I drag the custom activity and immediately click once on it.
Yes, I am able to reproduce the issue.
I have updated the above blog with the fix; please try and confirm.
Hi,
It works.. I’m not getting the error anymore. Thanks a lot.