Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background property does not point to a dependencyobject in path '(0).(1)'

I wrote this code and got an exception:

Background property does not point to a dependencyobject in path '(0).(1)'

I saw this problem in other posts in the forum but didn't founded a solution.

<WrapPanel.Style>
  <Style>
    <Style.Triggers>
      <Trigger Property "WrapPanel.Visibility" Value="Visible">                            
        <Trigger.EnterActions>
          <BeginStoryboard HandoffBehavior="Compose">
            <Storyboard RepeatBehavior="Forever" AutoReverse="True">
              <ColorAnimation 
                Storyboard.TargetProperty="(WrapPanel.Background).(SolidColorBrush.Color)"
                Duration="00:00:01" To="Red"/>
            </Storyboard>
          </BeginStoryboard>
        </Trigger.EnterActions>
      </Trigger>
    </Style.Triggers>
  </Style>
</WrapPanel.Style>

Any help with this?

like image 876
Maya Avatar asked Jul 01 '13 07:07

Maya


2 Answers

You most likely failed to set a value for the initial background brush. You can either do so with a style setter, or else just set a value on the panel directly. The style setter is probably better:

<Setter Property="Background">
    <Setter.Value>
        <SolidColorBrush Color="Blue"/>
    </Setter.Value>
</Setter>

Note that you can also specify the TargetType property on your style, so that you don't have to prefix all property reference with WrapPanel:

<Style TargetType="WrapPanel">
like image 57
dlev Avatar answered Nov 11 '22 20:11

dlev


You must set the Background property of the WrapPanel! Otherwise the WPF subsystem doesn't recognize it as a SolidColorBrush (could be another brush as well).

<WrapPanel Background="White">
...
</WrapPanel>

is sufficient.

like image 43
JeffRSon Avatar answered Nov 11 '22 19:11

JeffRSon