What is wrong with the custom attached property?
In visual studio I get "XAML parsing error" when a story board is run. The application launches but when I mouseover a button which has been templated, the error i开发者_JS百科s shown.
My buttons template (using visual states etc) has a circle that scales which is passed in via a custom attached property.
The code that raises the error at runtime is the value property below:
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="Document"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame KeyTime="00:00:00.7000000"
Value="{Binding Path=(local:MyAttachedProperties.Scaling), RelativeSource={RelativeSource TemplatedParent}}" />
</DoubleAnimationUsingKeyFrames>;
The code for the attached property is:
public class MyAttachedProperties
{
public static readonly DependencyProperty ScalingProperty =
DependencyProperty.RegisterAttached("Scaling",
typeof(double), typeof(MyAttachedProperties), null);
// Scaling
public static double GetScaling(DependencyObject obj)
{
return (double)obj.GetValue(ScalingProperty);
}
public static void SetScaling(DependencyObject obj, double value)
{
obj.SetValue(ScalingProperty, value);
}
}
and for my button I have:
<Button Height="76"
Content="Gallery"
Style="{StaticResource MyRotatingButtonStyle}"
Padding="10"
local:MyAttachedProperties.Scaling="2" />
In Silverlight you can't bind on an Animation object they don't derive from FrameworkElement
which is required in Silverlight 3 for binding to work.
To achieve your goal you will need to write some code to find the EasingDoubleKeyFrame
and adjust the value directly.
精彩评论