0xDEADBEEF

Hello Everyone,

I'm rehosting the WF designer in my own application. I'd like to be able to be notified when an Activities Name property changes. Actually, I'd like to be notified when any of the properties for any of the Activites on the designer change.

Does anyone know how to register / get notified in the designer when one of the Activities Name (or other properties) change

BTW, I also wanted to know in the designer when a user created / deleted an Activity. For those who are trying to figure out how to do the same thing...

// designerHost is an IDesignerHost you should have access to if your hosting the WF designer...

Activity rootActivity = designerHost.RootComponent as Activity;

SequentialWorkflowActivity mainWorkflowActivity = rootActivity as SequentialWorkflowActivity;

mainWorkflowActivity.Activities.ListChanged += new EventHandler<ActivityCollectionChangeEventArgs>(Activities_ListChanged);

void Activities_ListChanged(object sender, ActivityCollectionChangeEventArgs e)

{

if (e.Action == ActivityCollectionChangeAction.Add)

{

Console.WriteLine("User added an Activity to the designer.");

}

else if (e.Action == ActivityCollectionChangeAction.Remove)

{

Console.WriteLine("User deleted an Activity to the designer");

}

}

If you know of a better way to get notified when an Activity is added / removed please let me know.

Thanks,




Re: Windows Workflow Foundation Capturing an Activity.NameChanged Event in the Designer

sergey.chub

to get notifications when activity gets added/deleted or it's property gets updated, you should be using the IComponentChangeService.

just sync up the event that better suits your needs (e.g. ComponentAdded for addition of an activity or ComponentChanged for chaning of properties - just examine the event args to see what has changed).

there should also be a plenty of examples on how to use this service on the web - this is the same one used in the winforms.






Re: Windows Workflow Foundation Capturing an Activity.NameChanged Event in the Designer

0xDEADBEEF

THANK YOU!!!

IComponentChangeService makes life nice.

It seems like their is a fairly disjointed relationship between System.ComponentModel and System.Workflow.ComponentModel