summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs')
-rw-r--r--Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs
new file mode 100644
index 0000000..24c9a52
--- /dev/null
+++ b/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs
@@ -0,0 +1,28 @@
+´╗┐using System;
+using AppKit;
+
+namespace Xamarin.Forms.Platform.MacOS
+{
+ public static class PageExtensions
+ {
+ public static NSViewController CreateViewController(this Page view)
+ {
+ if (!Forms.IsInitialized)
+ throw new InvalidOperationException("call Forms.Init() before this");
+
+ if (!(view.RealParent is Application))
+ {
+ Application app = new DefaultApplication();
+ app.MainPage = view;
+ }
+
+ var result = new Platform();
+ result.SetPage(view);
+ return result.ViewController;
+ }
+
+ class DefaultApplication : Application
+ {
+ }
+ }
+} \ No newline at end of file