i'm struggling with setting attached properties out of a different project in a storyboard with xaml.
In the style of a textbox i have an eventtrigger which should set an attached property to true after an event.
XAML:
xmlns:MyNamespace="clr-namespace:Project.Utilities"
<EventTrigger RoutedEvent="SomeEvent">
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames
Storyboard.TargetProperty="MyNamespace:MyClass.MyAttachedProperty">
<DiscreteBooleanKeyFrame Value="True" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
C#:
namespace MyNamespace
{
public static class MyClass
{
public static readonly DependencyProperty MyAttachedPropertyProperty
= DependencyProperty.RegisterAttached("MyAttachedProperty", typeof(bool),
typeof(MyClass), new UIPropertyMetadata(false));
public static void SetMyAttachedProperty(DependencyObject target, bool value)
{
target.SetValue(MyAttachedPropertyProperty, value);
}
public static bool GetMyAttachedProperty(DependencyObject target)
{
return (bool)target.GetValue(MyAttachedPropertyProperty);
}
}
}
With the PropertyPath I did it like discribed in here. But I always get an 'System.InvalidOperationException' with: Additional information: Cannot resolve all property references in the property path 'MyNamespace:MyClass.MyAttachedProperty'. Verify that applicable objects support the properties.
I tried several different ways to write the path with parenthesise and without them but honestly I don't quite get it how the path has to be defined it even not with the help of the MSDN Post
Does anyone has an idea what else I could try to access the attached property?
Thanks in advance!