views:

328

answers:

1

Hi,

I'm trying to perform a color animation on the fill property of a polygon and getting this error - Cannot convert the value in attribute 'Style' to object of type 'System.Windows.Style'. Cannot resolve all property references in the property path 'Fill.Color'. Verify that applicable objects support the properties. Error at object 'System.Windows.Shapes.Polygon' in markup file.

Any ideas? Please see below my XAML style. Thanks.

<Style TargetType="{x:Type Polygon}" x:Key="ArrowStyle">
        <Style.Triggers>
            <DataTrigger Value="True">
                <DataTrigger.Binding>
                    <MultiBinding Converter="{StaticResource NumberIsLessThanParameter}">
                        <Binding Path="Value" Mode="OneWay"/>
                        <Binding Path="OldValue" Mode="OneWay"/>
                    </MultiBinding>
                </DataTrigger.Binding>
                <DataTrigger.EnterActions>

                    <BeginStoryboard Name="ToRedArrow">
                        <Storyboard TargetProperty="Fill.Color">
                            <ColorAnimation From="Transparent" To="Red" Duration="0:0:2" AutoReverse="False" />
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
            <DataTrigger  Value="False">
                <DataTrigger.Binding>
                    <MultiBinding Converter="{StaticResource NumberIsLessThanParameter}">
                        <Binding Path="Value" Mode="OneWay"/>
                        <Binding Path="OldValue" Mode="OneWay"/>
                    </MultiBinding>
                </DataTrigger.Binding>
                <DataTrigger.EnterActions>
                    <BeginStoryboard Name="ToBlueArrow">
                        <Storyboard TargetProperty="Fill.Color">
                            <ColorAnimation From="Transparent" To="Blue" Duration="0:0:2" AutoReverse="False"/>
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
        </Style.Triggers>
    </Style>
A: 

Hi Alberto,

Property path looks invalid. Try to change it to: (Shape.Fill).(SolidColorBrush.Color)

Anvaka
Now I get this error: Cannot convert the value in attribute 'Style' to object of type 'System.Windows.Style'. 'Fill' property does not point to a DependencyObject in path '(0).(1)'. Error at object 'System.Windows.Shapes.Polygon' in markup file.
Alberto
Looks like the error was due to the Fill property not being initialized. But now I get an odd behaviour - it never turns red.
Alberto