Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 100875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:39:46+00:00 2026-05-11T00:39:46+00:00

PHEW. I’m serious. I’ll spell it out as follows… The Storyboard has a Key

  • 0

PHEW.

I’m serious. I’ll spell it out as follows…

The Storyboard has a Key ‘myStoryboard’. It’s held in a DataTemplate with a key ‘myDataTemplate’.

This data template is used in a ContentControl with the name ‘myContentControl’ by this tag:

<ContentControl Name='myContentControl'      ContentTemplate='{DynamicResource myDataTemplate}'/>  

The content control is used in my UserControl. In the UserControl codebehind I’ve made a keyboard gesture that supposed to start ‘myStoryBoard’ but i’m having no such luck getting to it.

private void StartSB(object sender, ExecutedRoutedEventArgs e)  {    Storyboard sb = (Storyboard) this.TryFindResource('myStoryboard');    sb.Begin(this);   }  

sb is always null here. How can i get the Storyboard?

UPDATE:

so playing with TryFindResource() I’ve managed to get to myDataTemplate

private void StartSB(object sender, ExecutedRoutedEventArgs e)  {    object sb = this.myContentControl.TryFindResource('myDataTemplate');   }  

in the Locals viewer I can see sb is myDataTemplate. I can see in the tree sb.base.Resources.Keys which is an array of resources in which ‘myStoryboard’ is inside. Oh so close!

UPDATE2:

More code complete here. I realize now this may be too spaghettified to explain with words.

<UserControl >    <UserControl.Resources>    <ResourceDictionary>         <ResourceDictionary.MergedDictionaries>             <ResourceDictionary Source='Resources\myUCResources.xaml' />         </ResourceDictionary.MergedDictionaries>     </ResourceDictionary>   </UserControl.Resources>   <ContentControl Name='myContentControl'              ContentTemplate='{DynamicResource myDataTemplate}'                 Content='{Binding}' />    ...  </UserControl>  

now the codebehind for this User control

namespace myclass  {    public partial class myUserControl: UserControl,  System.ComponentModel.INotifyPropertyChanged     {       ...        public myUserControl()        {           InitializeComponent();            <!--setup keybinding-->        }         public void KeyBindExecuted(object sender, ExecutedRoutedEventArgs e)        {           Object sb = this.myContentControl.TryFindResource('myDataTemplate');            //sb returns the DataTemplate        }      }  }  

And finally the resource dictionary containing the UI stuff and the animation I ultimately want to trigger. (myUCResources.xaml)

<ResourceDictionary>      <DataTemplate x:Key='myDataTemplate' >          <Grid>             <!-- elements like buttons -->          </Grid>          <DataTemplate.Resources>              <Storyboard x:Key='myStoryBoard'>                  <DoubleAnimation>                      <!-- animation stuff-->                  </DoubleAnimation>               </Storyboard>          </DataTemplate.Resources>          <DataTemplate.Triggers>              <EventTrigger SourceName='aButton' RoutedEvent='Button.Click'>                   <BeginStoryboard Storyboard='{StaticResource myStoryBoard}' />                 </EventTrigger>         </DataTemplate.Triggers>      </DataTemplate>  </ResourceDictionary>  

Update 3:

ok different approach. Can I use the EventTrigger in the DataTemplate from the codebehind to start the animation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:39:47+00:00Added an answer on May 11, 2026 at 12:39 am

    AH HAH!

    So I found a roundabout way to solving this. My third update where I entertained the thought of just firing an event seemed more fruitful. All can be found here.

    http://www.codeproject.com/script/Forums/View.aspx?fid=1004114&msg=2827455

    In a nutshell I used FindResource to get the DataTemplate, then FindName of the button in the DataTemplate used to normally trigger the animation. Then I raised a button click on that button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I think the common concensus would be use a custom… May 11, 2026 at 10:13 am
  • added an answer Don't use TheDefaultIsConcreteType before enrich. That would be just like… May 11, 2026 at 10:13 am
  • added an answer Join after the filters (e.g. join the results), don't try… May 11, 2026 at 10:13 am

Related Questions

PHEW. I'm serious. I'll spell it out as follows... The Storyboard has a Key
I'm running a master-slave MySQL binary log replication system (phew!) that, for some data,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.