我有一个具有边框的用户控件,边框的颜色应设置为依赖属性。我也想动画边框的不透明度。我目前的XAML代码如下所示:无法解析属性路径中的所有属性引用
<Border BorderBrush="{Binding ElementName=ImageViewerUserControl,
Path=NotificationColor}" BorderThickness="3" x:Name="AnimatedBorderBrush"
Visibility="{Binding ElementName=ImageViewerUserControl,
Path=ShowSequenceErrorNotification, Converter={StaticResource boolToVisibility}}">
<Border.Triggers>
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="AnimatedBorderBrush"
Storyboard.TargetProperty="BorderBrush.Opacity"
RepeatBehavior="Forever"
AutoReverse="True"
From="1"
To="0.0"
Duration="0:0:1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
</Border>
此只给出错误:
Cannot resolve all property references in the property path 'BorderBrush.Opacity'. Verify that applicable objects support the properties.
但是,如果我换到BorderBrush的颜色,可以说Black
它的工作原理。这是如何实现的?我想通过依赖项属性设置我的边界的刷子颜色。是的,依赖属性是Brush
您是否为DependencyProperty设置了默认画笔?如果不是默认值是空的并且会导致这样的错误。 – LPL
@LPL我怎样才能做到这一点? –