Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
Animation is clunky when dynamically loading a user control
posted

I'm dynamically loading different UserControls based on the TileState of a TilePane within my xamTileView control. I'm loading the control based on the xamTileView.MaximizedStateChanged event, so I thought the entire animation would be finished by then. Everything was working great until I started adding some business logic to one of the UserControls. Now, the first time that TilePane enters the state where that user control will load, the animation has disappeared. It's almost like the animation has been trumped by loading the UserControl.

I'd realy like to keep the animation on the first maxizing of a tile... any ideas on how I could address this? Maybe there's a better event to trap?

Parents
No Data
Reply
  • 3071
    Verified Answer
    posted

    Hi,
    The animation may disappear because the user control causes additional layout changes after adding an additional business logic initialization.
    You can add this logic in AnimationCompleted event-handler.
    This sample code demonstrates how to work with AnimationCompleted event:
    TilePane _tile;
    void tileView_MaximizedStateChanged(object sender, TileStateChangedEventArgs e)
    {
     
    TilePane pane = e.Element as TilePane;
     
    if (pane.Name == "tile11")
      {
        _tile = pane;
       
    if (e.NewState == TileState.Maximized)
        {
         
    // load some user control when the tile is maximized
         
    _tile.Content = new OutlookBar();
         
    // add an event handler to the AnimationCompleted event
         
    AnimatedPanel panel = pane.Parent as AnimatedPanel;
          panel.AnimationCompleted += Panel_AnimationCompleted;
        }
       
    else
       
    {
          _tile.Content =
    null;
        }
      }
    }
    void Panel_AnimationCompleted(object sender, EventArgs e)
    {
     
    AnimatedPanel panel = sender as AnimatedPanel;
      panel.AnimationCompleted -= Panel_AnimationCompleted;
     
    // put the UC initialization here
     
    _tile.Content = "AnimationCompleted";
    }

    Regards,
    Marin

Children