En studio visuel, je reçois une "erreur d'analyse XAML" lors de l'exécution d'un story-board. L'application se lance mais lorsque je souris sur un bouton qui a été modélisé, l'erreur est affichée.Quel est le problème avec la propriété attachée personnalisée?
Mon modèle de boutons (utilisant des états visuels, etc.) a un cercle qui est transmis par une propriété attachée personnalisée.
Le code qui déclenche l'erreur lors de l'exécution est la propriété de valeur ci-dessous:
<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>;
Le code de la propriété attachée est:
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);
}
}
et mon bouton je:
<Button Height="76"
Content="Gallery"
Style="{StaticResource MyRotatingButtonStyle}"
Padding="10"
local:MyAttachedProperties.Scaling="2" />
Silverlight ou WPF? C'est une question rare qui correspond aux deux. – AnthonyWJones
Salut Anthony, oui c'est silverlight. –