none
Error: Fill property does not point to a DependencyObject in path '(0).(1)'. RRS feed

  • Question

  • Error: Fill property does not point to a DependencyObject in path '(0).(1)'.

    I get this runtime error when I run my application with this code:

    Code Snippet

     

     

     

        <Window.Resources>

      <Style TargetType="{x:Type Rectangle}" x:Key="quoteColorChange">
       <Style.Triggers>
        <DataTrigger Binding="{Binding Mode=OneWay, XPath=@cdir}" Value="1">
         <DataTrigger.EnterActions>
          <BeginStoryboard>
             <Storyboard>
          <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
            <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF9D0000"/>
            <SplineColorKeyFrame KeyTime="00:00:01" Value="#FF000000"/>
          </ColorAnimationUsingKeyFrames>
         </Storyboard>
          </BeginStoryboard>
         </DataTrigger.EnterActions>
        </DataTrigger>       
       </Style.Triggers>
       
      </Style>

        </Window.Resources>

    ...

     

           <Rectangle HorizontalAlignment="Stretch" Margin="8,42.919,8,29.16" Width="Auto" StrokeThickness="0" RadiusX="8" RadiusY="8" Style="{DynamicResource quoteColorChange}">

     

    ...

     

     

    I am trying to animate the fill color change of the rectangle depending on the value of the data binding field "@cdir".

     

    Please tell me what I'd doing wrong?

    Tuesday, March 4, 2008 2:19 PM

Answers

  • Here is an XAMLPad ready example on how to enable this type of animation:

    Code Snippet
    <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <
    Page.Resources>
    <
    Style TargetType="{x:Type Rectangle}" x:Key="quoteColorChange">
    <
    Style.Triggers>
    <
    DataTrigger Binding="{Binding}" Value="1">
    <
    DataTrigger.EnterActions>
    <
    BeginStoryboard>
    <
    Storyboard>
    <
    ColorAnimationUsingKeyFrames
    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
    <
    SplineColorKeyFrame KeyTime="00:00:00" Value="#FF9D0000"/>
    <
    SplineColorKeyFrame KeyTime="00:00:02" Value="#FF000000"/>
    </
    ColorAnimationUsingKeyFrames>
    </
    Storyboard>
    </
    BeginStoryboard>
    </
    DataTrigger.EnterActions>
    </
    DataTrigger>
    </
    Style.Triggers>
    </
    Style>
    </
    Page.Resources>
    <
    Rectangle RadiusX="8" RadiusY="8" Style="{StaticResource quoteColorChange}" DataContext="1">
    <
    Rectangle.Fill>
    <
    SolidColorBrush/>
    </
    Rectangle.Fill>
    </
    Rectangle>
    </
    Page>

    Hope this helps
    Thursday, March 6, 2008 6:23 AM

All replies

  • So what's the value of @cdir in your case?

     

    Wednesday, March 5, 2008 3:31 PM
  • Here is an XAMLPad ready example on how to enable this type of animation:

    Code Snippet
    <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <
    Page.Resources>
    <
    Style TargetType="{x:Type Rectangle}" x:Key="quoteColorChange">
    <
    Style.Triggers>
    <
    DataTrigger Binding="{Binding}" Value="1">
    <
    DataTrigger.EnterActions>
    <
    BeginStoryboard>
    <
    Storyboard>
    <
    ColorAnimationUsingKeyFrames
    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
    <
    SplineColorKeyFrame KeyTime="00:00:00" Value="#FF9D0000"/>
    <
    SplineColorKeyFrame KeyTime="00:00:02" Value="#FF000000"/>
    </
    ColorAnimationUsingKeyFrames>
    </
    Storyboard>
    </
    BeginStoryboard>
    </
    DataTrigger.EnterActions>
    </
    DataTrigger>
    </
    Style.Triggers>
    </
    Style>
    </
    Page.Resources>
    <
    Rectangle RadiusX="8" RadiusY="8" Style="{StaticResource quoteColorChange}" DataContext="1">
    <
    Rectangle.Fill>
    <
    SolidColorBrush/>
    </
    Rectangle.Fill>
    </
    Rectangle>
    </
    Page>

    Hope this helps
    Thursday, March 6, 2008 6:23 AM