Example #1
0
        private /*async*/ void RefreshControlRefreshRequested(Microsoft.UI.Xaml.Controls.RefreshContainer sender, Microsoft.UI.Xaml.Controls.RefreshRequestedEventArgs args)
        {
            using (var RefreshCompletionDeferral = args.GetDeferral())
            {
                switch (_tabLayoutType)
                {
                case TabLayoutType.Item1ContentState:
                    RefreshAction1?.Invoke();
                    break;

                case TabLayoutType.Item2ContentState:
                    RefreshAction2?.Invoke();
                    break;

                case TabLayoutType.Item3ContentState:
                    RefreshAction3?.Invoke();
                    break;

                case TabLayoutType.Item4ContentState:
                    RefreshAction4?.Invoke();
                    break;

                case TabLayoutType.Item5ContentState:
                    RefreshAction5?.Invoke();
                    break;

                case TabLayoutType.Item6ContentState:
                    RefreshAction6?.Invoke();
                    break;

                default:
                    break;
                }
            }
        }
Example #2
0
        private async void OnFrameworkElementTapped(object sender, TappedRoutedEventArgs e)
        {
            if (sender is ContentPresenter contentPresenter)
            {
                var tag = contentPresenter.Tag.ToString();
                switch (_tabLayoutType)
                {
                case TabLayoutType.Item1ContentState:
                    Item1VerticalOffset = MainScrollViewer.VerticalOffset;
                    break;

                case TabLayoutType.Item2ContentState:
                    Item2VerticalOffset = MainScrollViewer.VerticalOffset;
                    break;

                case TabLayoutType.Item3ContentState:
                    Item3VerticalOffset = MainScrollViewer.VerticalOffset;
                    break;

                case TabLayoutType.Item4ContentState:
                    Item4VerticalOffset = MainScrollViewer.VerticalOffset;
                    break;

                case TabLayoutType.Item5ContentState:
                    Item5VerticalOffset = MainScrollViewer.VerticalOffset;
                    break;

                case TabLayoutType.Item6ContentState:
                    Item6VerticalOffset = MainScrollViewer.VerticalOffset;
                    break;

                default:
                    break;
                }
                await Task.Delay(100).ConfigureAwait(false);

                _tabLayoutType = (TabLayoutType)Enum.Parse(typeof(TabLayoutType), tag);
                SetState(_tabLayoutType);
                await Task.Delay(100).ConfigureAwait(false);

                switch (_tabLayoutType)
                {
                case TabLayoutType.Item1ContentState:
                    if (Item1VerticalOffset > 0)
                    {
                        ScrollToVerticalOffset(Item1VerticalOffset);
                    }
                    if (!Item1Init)
                    {
                        RefreshAction1?.Invoke();
                        Item1Init = true;
                    }
                    break;

                case TabLayoutType.Item2ContentState:
                    if (Item2VerticalOffset > 0)
                    {
                        ScrollToVerticalOffset(Item2VerticalOffset);
                    }
                    if (!Item2Init)
                    {
                        RefreshAction2?.Invoke();
                        Item2Init = true;
                    }
                    break;

                case TabLayoutType.Item3ContentState:
                    if (Item3VerticalOffset > 0)
                    {
                        ScrollToVerticalOffset(Item3VerticalOffset);
                    }
                    if (!Item3Init)
                    {
                        RefreshAction3?.Invoke();
                        Item3Init = true;
                    }
                    break;

                case TabLayoutType.Item4ContentState:
                    if (Item4VerticalOffset > 0)
                    {
                        ScrollToVerticalOffset(Item4VerticalOffset);
                    }
                    if (!Item4Init)
                    {
                        RefreshAction4?.Invoke();
                        Item4Init = true;
                    }
                    break;

                case TabLayoutType.Item5ContentState:
                    if (Item5VerticalOffset > 0)
                    {
                        ScrollToVerticalOffset(Item5VerticalOffset);
                    }
                    if (!Item5Init)
                    {
                        RefreshAction5?.Invoke();
                        Item5Init = true;
                    }
                    break;

                case TabLayoutType.Item6ContentState:
                    if (Item6VerticalOffset > 0)
                    {
                        ScrollToVerticalOffset(Item6VerticalOffset);
                    }
                    if (!Item6Init)
                    {
                        RefreshAction6?.Invoke();
                        Item6Init = true;
                    }
                    break;

                default:
                    break;
                }
            }
            async void ScrollToVerticalOffset(double offset)
            {
                await Helper.RunOnUI(() =>
                {
                    MainScrollViewer.ScrollToVerticalOffset(offset);
                });
            }
        }