Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Control storyboard inside custom control...by code

Control storyboard inside custom control...by code

Scheduled Pinned Locked Moved WPF
questioncsswpfdebugging
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jayme65
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups