Blend's behavior would be almost useless if they did not support binding! I recreated your slope behavior and supports snapping in Blend 4 without problems, so I donโt know exactly where you did the wrong thing. Perhaps you can reproduce my simple example, and then indicate what is wrong with your setup.
Here is the (non-functional) tilt behavior with a dependency property:
public class TiltBehavior : Behavior<FrameworkElement> { public double TiltFactor { get { return (double)GetValue(TiltFactorProperty); } set { SetValue(TiltFactorProperty, value); } } public static readonly DependencyProperty TiltFactorProperty = DependencyProperty.Register("TiltFactor", typeof(double), typeof(TiltBehavior), new UIPropertyMetadata(0.0)); }
Then just create a new window and leave the behavior on the grid, and Blend will create this:
<Grid> <i:Interaction.Behaviors> <local:TiltBehavior/> </i:Interaction.Behaviors> </Grid>
and the Blend option "Data Binding ..." is available on the properties tab.
I tested this with both WPF projects and Silverlight. Built-in actions, triggers, and actions support binding through the use of dependency properties, and all Blend patterns use binding strongly, and therefore this one has .
In fact, you can simply add inline behavior, such as FluidMoveBehavior , to your grid and verify that Duration , which is a dependency property, supports binding. If this does not work, I have no idea what is happening!
Let's look then at how binding works for these strange animals called behavior.
As WPF or Silverlight programmers, we are very familiar with binding to things like FrameworkElement . It has a DataContext property that we can manipulate to control the default binding source, and this property is inherited by nested elements when we do not redefine it.
But the behavior (and triggers and actions) are not of type FrameworkElement . They are ultimately derived from DependencyObject , as you would expect. But although we can use the binding for any class derived from DependencyObject , our familiar DataContext not at this low-level level, so the binding should provide the source. This is not very convenient.
So the behavior (in WPF anyway) comes from Animatable and Animatable comes from Freezable . The Freezable class is a place where the simplicity of dependency objects intersects with the complexity of structure elements. The Freezable class is also the base class for more familiar things like brushes and image sources. These classes do not need the full complexity of the structure element, but they want to participate in the limited with the elements with which they are associated.
Using a complex magic process, Freezable instances acquire an inheritance context: it is most closely associated with the structure element, and when the default binding (one without a source) is used, Freezable uses this related element.
In fact, when you learn about behavior, AssociatedObject is a central concept; for behavior, this is what behavior is attached to. But itโs important that all Freezable objects can use their AssociatedObject 's DataContext by proxy.
All this magic - this Josh Smith causes:
So, all this leads to the assertion that due to Hillberg freezing, the Blend behavior supports binding, using the data context of the element associated with them as the default source. As a result of attachment to behavior, it seems that they โjust workโ without any effort on our part. Because of this, behavior is a thousand times more useful.