What is DependancyProperty for in terms of SharePoint Workflow?
Off late I have been working on SharePoint Workflow, in SharePoint 2010. While creating a Task activity, i ususally create task from workflow code behind like..
CreateTask task = sender as CreateTask;
task.TaskId = Guid.NewGuid();
SPWorkflowTaskProperties wtp = new SPWorkflowTaskProperties();
wtp.Percent开发者_如何学CComplete = (float)0.0;
wtp.AssignedTo = "DOMAIN\USER_DomainID"
I see from Workflow designer,For CreateTask activity property page also you can set SPWorkflowTaskProperties as either Field or as Property. When we create this property as Property, it creates DependancyProperty. I am not sure when to use Field and when to use Property ? and what is the use of each options ? Can someone explain please ?
Perhaps this will help: Using Dependency Properties (WF)
In a nutshell, dependency properties are properties on steroids. They support change notification, value inheritance, default values, data binding, coercion, animation, etc. Well in theory anyway.
The Workflow Foundation (which by the way was completely scrapped and replaced in .NET 4 - so SharePoint 2010 workflows are based on abandoned technology) made a completely boneheaded move and re-invented the whole dependency property system that was created for WPF. That's why if you search for DependencyProperty in MSDN you'll see two different entries in two different namespaces/assemblies. The workflow version is much more limited than the WPF version and they're not at all interchangeable.
But to answer your question, you shouldn't use the field directly. Always go through the CLR property that wraps the dependency property field.
精彩评论