private void grid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            NavigationRootPage rootPage = Window.Current.Content as NavigationRootPage;

            if (rootPage != null)
            {
                Frame rootFrame = (Frame)rootPage.FindName("rootFrame");
                if (rootFrame != null)
                {
                    Page page = rootFrame.Content as Page;
                    if (page != null)
                    {
                        ListView szListView = page.FindName("szListView") as ListView;
                        if (szListView != null)
                        {
                            var scroll = VisualTreeHelperEx.FindVisualChildByName <ScrollViewer>(szListView, "ScrollViewer");
                            if (scroll != null)
                            {
                                scroll.ScrollToVerticalOffset(0);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public Grid GetCurrentAnimationGrid()
        {
            NavigationRootPage rootPage = Window.Current.Content as NavigationRootPage;

            if (rootPage != null)
            {
                Frame rootFrame = (Frame)rootPage.FindName("rootFrame");

                if (rootFrame != null)
                {
                    Grid grid = VisualTreeHelperEx.FindVisualChildByName <Grid>(rootFrame.Content as Page, "AnimationGrid");
                    if (grid != null)
                    {
                        return(grid);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        //static ICommand listViewLoadMoreCommand;

        private static void element_Loaded(object sender, RoutedEventArgs e)
        {
            var d      = sender as FrameworkElement;
            var scroll = VisualTreeHelperEx.FindVisualChildByName <ScrollViewer>(d, "ScrollViewer");

            if (scroll != null)
            {
                //var scrollBar = VisualTreeHelperEx.FindVisualChildByName<ScrollBar>(scroll, "VerticalScrollBar");
                //if (scrollBar != null)
                //{
                //    scrollBar.Foreground = new SolidColorBrush(Color.FromArgb(255, 176, 14, 37));
                //    //Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
                //}

                var command = GetLoadMoreCommand(d);
                if (command != null)
                {
                    //scroll.ViewChanged -= Scroll_ViewChanged;
                    scroll.ViewChanged += (s, a) =>
                    {
                        ViewModelLocator.Instance.ListViewScroll();
                        ViewModelLocator.Instance.FavoriteOrDownloadListViewScroll();

                        //Debug.WriteLine("scroll.VerticalOffset : " + scroll.VerticalOffset + "scroll.ScrollableHeight : " + scroll.ScrollableHeight +  "  scroll.ScrollableHeight - 0.5 : " + (scroll.ScrollableHeight - 0.5));

                        if (scroll.VerticalOffset >= scroll.ScrollableHeight)
                        {
                            //if (!next)
                            //{
                            //next = true;
                            if (command.CanExecute(null))
                            {
                                command.Execute(null);
                            }
                            // }
                            //else
                            //{
                            //next = false;
                            //}
                        }
                    };
                }
            }
        }
Пример #4
0
        //static ICommand listViewLoadMoreCommand;

        private static void myElement_Loaded(object sender, RoutedEventArgs e)
        {
            var d      = sender as FrameworkElement;
            var scroll = VisualTreeHelperEx.FindVisualChildByName <ScrollViewer>(d, "ScrollViewer");

            if (scroll != null)
            {
                var command = GetScrollCommand(d);
                if (command != null)
                {
                    //scroll.ViewChanged -= Scroll_ViewChanged;
                    scroll.ViewChanged += (s, a) =>
                    {
                        if (command.CanExecute(null))
                        {
                            command.Execute(null);
                        }
                    };
                }
            }
        }
Пример #5
0
        public async void OnNavigatedTo(NavigationEventArgs e)
        {
            //一定要写在执行动画前面,这样就能Pivot设定好选择索引之后再显示Pivot
            if (e.SourcePageType == typeof(ChampionPage) || e.SourcePageType == typeof(ActPage) || e.SourcePageType == typeof(PlayPage) || e.SourcePageType == typeof(TeachPage) || e.SourcePageType == typeof(OfficialPage) || e.SourcePageType == typeof(SuperPage))
            {
                Pivot p = VisualTreeHelperEx.FindVisualChildByName <Pivot>(e.Content as DependencyObject, "pi");
                if (p != null)
                {
                    //New模式表明是从首页来的
                    if (e.NavigationMode == NavigationMode.New)
                    {
                        //这句话是在New的方式进入到NewsListPage的时候正确定位Pivot的Item的Index
                        p.SelectedIndex = DicStore.GetValueOrDefault <int>(AppCommonConst.CUR_PIVOT_SELECTED_INDEX, 0);
                    }
                    //back说明是返回的,从其他页面返回,此时应当回到进入其他页面之前的Pivot的Item的索引值
                    else
                    {
                        //p.SelectedIndex = DicStore.GetValueOrDefault<int>(AppCommonConst.CUR_PIVOT_SELECTED_INDEX, 0);
                    }
                }
            }

            var animationGrid = CommonHelper.Instance.GetCurrentAnimationGrid();

            if (e.NavigationMode == NavigationMode.Back)
            {
                if (animationGrid != null)
                {
                    if (AppEnvironment.IsPhone)
                    {
                        await animationGrid.AnimateAsync(new FadeInUpAnimation()
                        {
                            Distance = 400, Duration = 0.25
                        });
                    }
                    else
                    {
                        await animationGrid.AnimateAsync(new FadeInRightAnimation()
                        {
                            Duration = 0.13, Distance = 600
                        });
                    }
                }
            }

            var frameState = SuspensionManager.SessionStateForFrame(this.Frame);

            this._pageKey = "Page-" + this.Frame.BackStackDepth;

            if (e.NavigationMode == NavigationMode.New)
            {
                // Clear existing state for forward navigation when adding a new page to the
                // navigation stack
                var nextPageKey   = this._pageKey;
                int nextPageIndex = this.Frame.BackStackDepth;
                while (frameState.Remove(nextPageKey))
                {
                    nextPageIndex++;
                    nextPageKey = "Page-" + nextPageIndex;
                }

                // Pass the navigation parameter to the new page
                if (this.LoadState != null)
                {
                    this.LoadState(this, new LoadStateEventArgs(e.Parameter, null));
                }
            }
            else
            {
                // Pass the navigation parameter and preserved page state to the page, using
                // the same strategy for loading suspended state and recreating pages discarded
                // from cache
                if (this.LoadState != null)
                {
                    this.LoadState(this, new LoadStateEventArgs(e.Parameter, (Dictionary <String, Object>)frameState[this._pageKey]));
                }
            }

            if (animationGrid != null)
            {
                if (e.NavigationMode == NavigationMode.New)
                {
                    if (e.SourcePageType != typeof(NewsDetailPage))
                    {
                        //对非类别基页的进入动画
                        if (e.SourcePageType == typeof(ChampionPage) || e.SourcePageType == typeof(ActPage) || e.SourcePageType == typeof(PlayPage) || e.SourcePageType == typeof(TeachPage) || e.SourcePageType == typeof(OfficialPage) || e.SourcePageType == typeof(SuperPage))
                        {
                            if (AppEnvironment.IsPhone)
                            {
                                await animationGrid.AnimateAsync(new FadeInDownAnimation()
                                {
                                    Distance = 250, Duration = 0.3
                                });
                            }
                            else
                            {
                                await animationGrid.AnimateAsync(new FadeInLeftAnimation()
                                {
                                    Duration = 0.13, Distance = 600
                                });
                            }
                        }
                        //这里是类别切换进入动画
                        else
                        {
                            if (e.SourcePageType != typeof(MapPage) && e.SourcePageType != typeof(EncyPage))
                            {
                                if (AppEnvironment.IsPhone)
                                {
                                    await animationGrid.AnimateAsync(new FadeInLeftAnimation()
                                    {
                                        Duration = 0.25, Distance = 400
                                    });
                                }
                                else
                                {
                                    await animationGrid.AnimateAsync(new FadeInLeftAnimation()
                                    {
                                        Duration = 0.13, Distance = 600
                                    });
                                }
                            }
                        }
                    }
                }
                else if (e.NavigationMode == NavigationMode.Back)
                {
                    //TO-DO:做些事
                }
            }
        }