internal GoBackCommand(SettingsPage page)
 {
     this.page = page;
 }
Exemple #2
0
        protected internal virtual void OnSettingsCommandsRequested(IList<SettingsCommand> commands)
        {
            Settings.Current.Flyouts.Run(f =>
            {
                var label = Service.Current.Messages != null ? Service.Current.Messages[f.LabelMessageKey] : f.LabelMessageKey;
                commands.Add(new SettingsCommand(f, label,
                    cmd =>
                    {
                        var popup = new Popup();
                        popup.IsLightDismissEnabled = true;

                        f.Settings = Settings.Current;
                        var settingsPage = new SettingsPage { DataContext = f };

                        settingsPage.Width = popup.Width = SettingsPage.PaneWidth;
                        settingsPage.Height = popup.Height = ((Frame)Window.Current.Content).ActualHeight;

                        popup.Child = settingsPage;

                        popup.SetValue(Canvas.LeftProperty, ((Frame)Window.Current.Content).ActualWidth - SettingsPage.PaneWidth);
                        popup.SetValue(Canvas.TopProperty, 0);

                        popup.Opened += (_, __) => ((StoreHooks)Service.Current.Hooks).SettingsVisibilityChanged(settingsPage, true);
                        popup.Closed += (_, __) => ((StoreHooks)Service.Current.Hooks).SettingsVisibilityChanged(settingsPage, false);

                        WindowActivatedEventHandler activatedHandler = null;
                        activatedHandler = (_, e) =>
                        {
                            if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
                            {
                                Window.Current.Activated -= activatedHandler;
                                popup.IsOpen = false;
                            }
                        };

                        Window.Current.Activated += activatedHandler;

                        popup.IsOpen = true;
                    }));
            });
        }