I have a custom user control that registrates a dependency property HoverHeight:
public sealed partial class VirtualPointer : UserControl
{
public static readonly DependencyProperty HoverHeightProperty =
DependencyProperty.Register("HoverHeight", typeof(double),
typeof(VirtualPointer), new PropertyMetadata(1.0,OnHoverHeightChanged));
public double HoverHeight
{
get { return (double)GetValue(HoverHeightProperty); }
set { SetValue(HoverHeightProperty, value); }
}
...
I use this property to calculate the Margins of some child controls in combination with an according IValueConverter.
In a page that uses this control, I create a Storyboard which should animate the HoverHeight property:
<Page ...>
<Page.Resources>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="virtualPointer" Storyboard.TargetProperty="HoverHeight">
<LinearDoubleKeyFrame Value="1.0" KeyTime="0:0:0"/>
<LinearDoubleKeyFrame Value="0.0" KeyTime="0:0:1"/>
<LinearDoubleKeyFrame Value="1.0" KeyTime="0:0:2"/>
<LinearDoubleKeyFrame Value="0.0" KeyTime="0:0:3"/>
<LinearDoubleKeyFrame Value="1.0" KeyTime="0:0:4"/>
</DoubleAnimationUsingKeyFrames>
<!-- other DoubleAnimationUsingKeyFrames -->
</Storyboard>
</Page.Resources>
<!-- ... -->
<local:VirtualPointer Name="virtualPointer" HoverHeight="0.5"/>
</Page>
The storyboard contains other animations which work as expected. However, when I start the storyboard the HoverHeight value does not change. Neither the OnHoverHeightChanged handler is called, nor the converter with the new value. I can set a new value with the property setter which in turn calls the OnHoverHeightChanged handler, so there is probably a problem with the animation.
There is no output or exception generated when starting the storyboard.
Am I missing something here? How can I animate the custom dependency property?
<local:VirtualPointer/>is the child element of a grid in a window. The<Storyboard>is defined in a<Window.Resources>providing ax:Key. - Nico Schertler