locked
Animation for screen with TabControl RRS feed

  • Question

  • I'm trying to create an animation that shows a screen on which there is a tab control with three tabs and selects each tab in turn. 

    So I predefined three TabItems, select first one, that's my first frame. Then create new frame, select second tab; create new frame, select third tab.

    However, when I click "play animation", the tab selection does not change: the first tab remains selected, so the content of the second and third tab is never shown, eventhough on the animation you can see the yellow box around the animation frame moving from one frame to the next.

    Any ideas on how to get this simple effect?

     

    Friday, April 16, 2010 1:57 AM

Answers

  • The selection of a tab control is not something that can be animated in this way.  If you want to do this I'm afraid you will have to either fake it using multiple tab controls and animating them into/out of view, or do it in code.
    • Marked as answer by Schollii Sunday, April 18, 2010 3:50 AM
    Friday, April 16, 2010 1:32 PM
    Moderator

All replies

  • The selection of a tab control is not something that can be animated in this way.  If you want to do this I'm afraid you will have to either fake it using multiple tab controls and animating them into/out of view, or do it in code.
    • Marked as answer by Schollii Sunday, April 18, 2010 3:50 AM
    Friday, April 16, 2010 1:32 PM
    Moderator
  • That's good to know, thanks. I know a bit of C# (tons of C++ but still learning C#) so code-wise I wouldn't have a problem, but I'm wondering how the animation would call the code or what would trigger the code to run based on the animation.

    Another venue might be to use a trigger that changes the selected tab. The trigger would monitor some property that gets changed because of the animation. Is something like that possible? For instance, can a trigger monitor if the opacity of something gets larger than 50%? If the animation changes the opacity of that widget to above 50%, then wouldn't that an action that could be set to "change the selected tab of tab control"?

     

    Friday, April 16, 2010 6:01 PM
  • If you are comfortable with code, I would probably just use a timer to animate what you want.  Otherwise, to make it work with other animations, you could attach to the storyboard's events to switch tabs, and start another storyboard at the end.  Is the SL or WPF?  I can post an example.
    Friday, April 16, 2010 6:23 PM
    Moderator
  • WPF.
    Friday, April 16, 2010 7:05 PM
  • Clearly this isn't nearly as nice as using a storyboard, but you could do something like this:

    public MainWindow()
    		{
    			this.InitializeComponent();
    
    			this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
    		}
    
    		DispatcherTimer timer;
    		void MainWindow_Loaded(object sender, RoutedEventArgs e)
    		{
    			timer = new DispatcherTimer();
    			timer.Tick += new EventHandler(timer_Tick);
    			timer.Interval = TimeSpan.FromMilliseconds(1000);
    			timer.Start();
    		}
    
    		private int selected = 1;
    		void timer_Tick(object sender, EventArgs e)
    		{
    			
    			this.TabControl.SelectedIndex = selected++;
    			if (selected == 3)
    			{
    				timer.Stop();
    			}
    		}

    Friday, April 16, 2010 8:23 PM
    Moderator