July 18, 2007
@ 06:48 AM
  1. Oct. 25, 1978: First pet goldfish died. Realized living things die. Cried for weeks.
  2. Dec. 25, 1980: Opened gift from "Santa" that I had seen in parent's closet. Realized Santa is a lie. 
  3. July 16, 2007: Couldn't get this code to compile:

  ...realized that System.Windows.DependencyProperty and System.Workflow.ComponentModel.DependencyProperty are two entirely different classes. Only System.Windows.DependencyProperty, or more precisely System.Windows.PropertyMetadata supports the nifty CoerceValue callback.

I wonder why we have two separate families of DependencyProperty related stuff? Seems really weird and poorly thought out. Kind of "Hack"-ish.

What really hurts is that there doesn't seem to be a good way to coerce custom type dependency properties in WF-land. The answer is right there in WPF's PropertyMetadata, but we can't use it in WF.

The thing I was really trying to do was have a generic iterator-like activity that contained custom activities with custom type dependency properties. Like a ForEach activity that contained a custom Activity like "LoadPortfolio" with a Dependency Property called "Client" that was a custom type. The ForEach has a DataItem property it sets to the current item it is iterating in the context of each child, but because ForEach is general purpose, the type of DataItem is System.Object.

It would be easy to coerce DataItem to "Client" (just cast or use "as"!) but there doesn't seem to be a mechanism to do this in WF, and because of the type mismatch, my workflow can't even load.

So do I make a special ForEach for each type I want to iterate over? Do I change the Client property on my LoadPortfolio activity to type System.Object?

Hopefully I'll find a way to work around this that I can live with soon.


 
Categories: wf | wpf