maui-linux/Xamarin.Forms.ControlGaller.../SecondaryWindowService.cs

37 строки
1.1 KiB
C#
Исходник Обычный вид История

using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Xamarin.Forms;
using Xamarin.Forms.ControlGallery.WindowsUniversal;
using Xamarin.Forms.Controls;
using Xamarin.Forms.Platform.UWP;
[assembly: Dependency(typeof(SecondaryWindowService))]
namespace Xamarin.Forms.ControlGallery.WindowsUniversal
{
class SecondaryWindowService : ISecondaryWindowService
{
public async Task OpenSecondaryWindow(Type pageType)
{
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
var frame = new Windows.UI.Xaml.Controls.Frame();
[UWP] Multi-window (#2432) * Changes to support multiple windows on UWP * Locker on Layout.cs to prevent concurrency * Changes on UnitTests to work with multi-window * implemented Xamarin.Forms.Core and UAP Element.Dispatcher * Implementation on each platform * Implementation on each platform * Improved Element casting for Dispatcher utilization * Correction of the items presented in the code review * Control Gallery for Multiple Window and Code Review * [UnitTests]Add missing file * Correction for Unit Tests * Correction for Unit Tests * Correction for Unit Tests - Removed ThreadStatic in Ticker * removed thread static * removed thread static into application class * Update Control Gallery * Code Review (Changes) * Comment * Adjust StackOverflow when close the app * Performace improvements * - fix merge and ui test performance * Name of method and adjust on NavigationProxy * Adjustments in the implementation of the DispatcherManager * Updated the ListProxy method and adjust the initialization of dispacther on page. * Remove GetDispacther method from IPlatformServices and some adjusments of code review. * Adjust after merge on NavigationProxy * Register IDispatcherProvider on Xamarin.Forms.Core.UnitTests * Adjustments for correct unit tests operation * Adjustments for correct unit tests operation * remove spaces * Adjust for UITests * Remove IsInvokeRequired and adjusted de instance of s_resolutionList * Remove lock() on ResolveLayoutChanges method * Make IDispatcher implementations internal * Removed Dispatcher association from Element and Page class. Removed Child Assignment in Element Class and ThreadStatic Removal from NavigationProxy Property * Remove DispatcherManager; contain thread static to UWP implementation * Make dispatcher lazy * MockDispatcherProvider on Xaml.UnitTests * Add mock Dispatcher and DispatcherProvider for XAML unit tests * Revert "Add mock Dispatcher and DispatcherProvider for XAML unit tests" This reverts commit 134320d348a3812e44507ae0b50459c8f43478e9. * Add MockDispactcherProvider on Pager.UnitTests * Revert covariance change * Centralize dispatcher checking logic * Add a fallback dispatcher for platforms without a registered DispatcherProvider * Remove Dispatcher/DispatcherProvider from project * Allow UI test pages which use ListProxy to get a dispatcher in UITest mode * Prevent crash instantiating UITest version of Issue2004 * Removed unnecessary old codes * Clean up whitespace changes * Remove unused method
2019-08-15 20:36:38 +03:00
//The page instance must be created inside the new UI Thread.
ContentPage instance = (ContentPage)Activator.CreateInstance(pageType);
frame.Navigate(instance);
Window.Current.Content = frame;
Window.Current.Activate();
newViewId = ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
}
}
}