This question already has answers here:
This is what I have
- A ControlTemplate for a button in my window.resource, having an ellipse with an outerglow (named -- TasksToggleButtonOuterGlowBitmapEffect) and a text
- A button that is using this template
This is what I need
1. A storyboard that operates on the outerglow of the above mentioned ellipse 2. I shall trigger this storyboard from my codebehind file at any moment
When I tried this with the following snippet, the framework gives me a runtime exception stating that it is not able to find the control, 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>
Update -- I want this to be in the resource so that any button can use it