Example #1
0
        public async Task<bool> TryCreateNewWindowAsync(TabViewViewModel tabView, Size size)
        {
            CoreApplicationView newView = CoreApplication.CreateNewView();

            int newViewId = 0;

            await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                ApplicationView applicationView = ApplicationView.GetForCurrentView();
                applicationView.SetPreferredMinSize(new Size(MinWindowWidth, MinWindowHeight));
                applicationView.TryResizeView(size);

                Frame frame = new Frame();
                frame.Navigate(typeof(AppWindowPage), new TabViewNavigationParameters(tabView));

                Window.Current.Content = frame;

                Window.Current.Activate();

                newViewId = ApplicationView.GetForCurrentView().Id;
            });

            bool success = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);

            return success;
        }
Example #2
0
        public AppWindowPage()
        {
            InitializeComponent();

            DataContext = new TabViewViewModel();
            ViewModel.Tabs.CollectionChanged += OnTabsChanged;

            CoreApplicationViewTitleBar titleBar = CoreApplication.GetCurrentView().TitleBar;

            UpdateTitleBarLayout(titleBar);

            titleBar.LayoutMetricsChanged += (s, e) => UpdateTitleBarLayout(s);
        }
Example #3
0
        public async Task<bool> TryCreateNewWindowAsync(TabViewViewModel tabView, Size size)
        {
            AppWindow appWindow = await AppWindow.TryCreateAsync();

            Frame frame = new Frame();
            frame.Navigate(typeof(AppWindowPage), new TabViewNavigationParameters(tabView, appWindow));

            ElementCompositionPreview.SetAppWindowContent(appWindow, frame);

            WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(MinWindowWidth, MinWindowHeight));
            appWindow.RequestSize(size);

            appWindow.TitleBar.ExtendsContentIntoTitleBar = true;
            appWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent;
            appWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            appWindow.RequestMoveAdjacentToCurrentView();

            bool success = await appWindow.TryShowAsync();

            return success;
        }
 public TabViewNavigationParameters(TabViewViewModel tabView) : this(tabView, null)
 {
 }
 public TabViewNavigationParameters(TabViewViewModel tabView, AppWindow?appWindow)
 {
     TabView   = tabView;
     AppWindow = appWindow;
 }