コード例 #1
0
ファイル: ViewService.cs プロジェクト: smassjp/Template10
        public async Task <IViewLifetimeControl> OpenAsync(UIElement content, string title = null,
                                                           ViewSizePreference size         = ViewSizePreference.UseHalf)
        {
            this.Log($"Frame: {content}, Title: {title}, Size: {size}");

            var currentView = ApplicationView.GetForCurrentView();

            title = title ?? currentView.Title;

            var newView    = CoreApplication.CreateNewView();
            var dispatcher = DispatcherEx.Create(newView.Dispatcher);
            var newControl = await dispatcher.Dispatch(async() =>
            {
                var control      = ViewLifetimeControl.GetForCurrentView();
                var newWindow    = Window.Current;
                var newAppView   = ApplicationView.GetForCurrentView();
                newAppView.Title = title;

                // TODO: (Jerry)
                // control.NavigationService = nav;

                newWindow.Content = content;
                newWindow.Activate();

                await ApplicationViewSwitcher
                .TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.Default, currentView.Id, size);
                return(control);
            }).ConfigureAwait(false);

            return(newControl);
        }
コード例 #2
0
        internal WindowEx(Window window)
        {
            this.Log();

            Two.Window = window;
            Dispatcher = DispatcherEx.Create(window.Dispatcher);
            window.CoreWindow.Closed += (s, e) => WindowExManager.Instances.Remove(this);
            window.Closed            += (s, e) => WindowExManager.Instances.Remove(this);
            window.Activate();

            IsMainView = CoreApplication.MainView == CoreApplication.GetCurrentView();

            _displayInformation = new Lazy <DisplayInformation>(() =>
            {
                Two.Window.Activate();
                return(Dispatcher.Dispatch(() => DisplayInformation.GetForCurrentView()));
            });
            _applicationView = new Lazy <ApplicationView>(() =>
            {
                Two.Window.Activate();
                return(Dispatcher.Dispatch(() => ApplicationView.GetForCurrentView()));
            });
            _uIViewSettings = new Lazy <UIViewSettings>(() =>
            {
                Two.Window.Activate();
                return(Dispatcher.Dispatch(() => UIViewSettings.GetForCurrentView()));
            });
        }