Programmatically slide to next Panorama item

前端 未结 5 1908
-上瘾入骨i
-上瘾入骨i 2021-01-06 00:43

Is it possible to programmatically move from one panorama page/item to the next and get the same kind of animated sliding effect you get when sliding with a

5条回答
  •  攒了一身酷
    2021-01-06 01:28

    Its possible, just put the setting of the DefaultItem between a SlideTransition Completed event and you are done:

    public static class PanoramaExtensions
    {
        public static void SlideToPage(this Panorama self, int item)
        {
    
            var slide_transition = new SlideTransition() { };
            slide_transition.Mode = SlideTransitionMode.SlideLeftFadeIn;
            ITransition transition = slide_transition.GetTransition(self);
            transition.Completed += delegate
            {
                self.DefaultItem = self.Items[item];
                transition.Stop();
            };
            transition.Begin();
        }
    }
    

    Use my_panorama.SlideToPage(1) to slide to the second page.

提交回复
热议问题