Control storyboard inside custom control...by code
WPF
1
Posts
1
Posters
0
Views
1
Watching
-
Hello, How do I please control (start, stop, pause, go to specific time) a controltemplate storyboard inside a custom control..by code? The XAML:
<Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}" x:Name="CTarrow"> <ControlTemplate.Resources> <Storyboard x:Key="Storyboard1" RepeatBehavior="Forever" AutoReverse="True"> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="rectangle"> <DiscreteColorKeyFrame KeyTime="0" Value="#FF0080FF"/> <DiscreteColorKeyFrame KeyTime="0:0:0.5" Value="#FF004D99"/> <DiscreteColorKeyFrame KeyTime="0:0:0.8" Value="#FF0080FF"/> </ColorAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <Grid> <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Center" VerticalAlignment="Center" /> <Rectangle x:Name="rectangle" Height="30" Width="50" Fill="Black" /> </Grid> </ControlTemplate> </Setter.Value> </Setter>
In these 3 attemps, the debugger complains about not being able to resolve 'rectangle':
Dim myStoryboard As New Storyboard
myStoryboard = Arrow.FindResource("Storyboard1")
myStoryboard.Begin()Dim myStoryboard As New Storyboard
myStoryboard = CType(Me