这就是我所拥有的
- 我的 window.resource 中一个按钮的 ControlTemplate,有一个带有外发光的椭圆(名为TasksToggleButtonOuterGlowBitmapEffect)和一个文本
- 使用此模板的按钮
这就是我需要的
1. 在上述椭圆的外发光上运行的故事板 2. 我将随时从我的代码隐藏文件中触发这个故事板
当我使用以下代码段尝试此操作时,框架给了我一个运行时异常,指出它无法找到控件TasksToggleButtonOuterGlowBitmapEffect
<Window.Resource>
<ControlTemplate x:Key="DefaultTasksToggleButtonTemplate" TargetType="ToggleButton">
<Grid Margin="2">
<Border BorderBrush="White" BorderThickness="2" CornerRadius="20">
<Border.BitmapEffect>
<OuterGlowBitmapEffect x:Name="TasksToggleButtonOuterGlowBitmapEffect" GlowColor="LightGray" />
</Border.BitmapEffect>
</Border>
<Ellipse Fill="Red" Width="20" Height="20" Margin="2" />
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
<Storyboard x:Key="GlowStoryboard">
<DoubleAnimation Storyboard.TargetName="TasksToggleButtonOuterGlowBitmapEffect" Storyboard.TargetProperty="GlowSize" From="5" To="10" />
</Storyboard>
</Window.Resources>
更新——我希望它在资源中,以便任何按钮都可以使用它