I have the following property definition:
public static class Extensions
{
public static readonly DependencyProperty TestProperty = DependencyProperty.RegisterAttached("Test", typeof(Storyboard), typeof(UIElement), new UIPropertyMetadata(null));
public static void SetTest(UIElement element, Storyboard value)
{
element.SetValue(TestProperty, value);
}
public static Storyboard GetTest(UIElement element)
{
return (Storyboard)element.GetValue(TestProperty);
}
}
And try it use in the xaml
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Application;assembly=Application"
x:Name="template"
Height="40" Width="1460">
<Grid Background="#FF000000">
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left" TextAlignment="Left" FontSize="32">Example</TextBlock>
</Grid>
<UserControl.Style>
<Style>
<Setter Property="local:Extensions.Test">
<Setter.Value>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="template" From="270" To="360" Duration="0:0:1" Storyboard.TargetProperty="Angle" />
</Storyboard>
</Setter.Value>
</Setter>
</Style>
</UserControl.Style>
</UserControl>
when i try to load such xaml (for example using XamlReader.Load(stream);
), i get the exception with the following message
'local:Extensions.Test' property is not a valid DependencyProperty on the type 'Application.Extensions'. Verify that the property has a DependencyProperty defined with a member field that ends with the 'Property' suffix. Error at object 'System.Windows.Setter'.
Can anybody help me with this problem?
thanks in advance!