我有一個具有邊框的用戶控件,邊框的顏色應設置爲依賴屬性。我也想動畫邊框的不透明度。我目前的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我怎樣才能做到這一點? –