背景属性不指向路径的DependencyObject'(0)(1)“ [英] Background property does not point to a dependencyobject in path '(0).(1)'
问题描述
我写这篇code,并得到例外:背景属性没有指向的DependencyObject路径。(0)(1)
I wrote this code and got exception: Background property does not point to a dependencyobject in path '(0).(1)'
中的我其他帖子看到这个问题在论坛上但没有建立一个解决方案。
I saw this problem in other posts in the forum but didnt 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? Thanks
推荐答案
您最有可能无法设置为初始背景画笔的值。你可以用一种风格的setter这样做,否则干脆直接在面板上设置一个值。风格二传手可能是更好的:
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>
请注意,您也可以指定你的风格的的TargetType
属性,这样你就不必preFIX与 WrapPanel
:
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">
这篇关于背景属性不指向路径的DependencyObject'(0)(1)“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!