summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.MacOS/Renderers/PageControllerDelegate.cs
blob: d1f40d31a1554e5bb9dc92cab6ab7aee0cbf750c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
´╗┐using AppKit;
using Foundation;

namespace Xamarin.Forms.Platform.MacOS
{
	internal class PageControllerDelegate : NSPageControllerDelegate
	{
		public override string GetIdentifier(NSPageController pageController, NSObject targetObject)
		{
			return nameof(PageRenderer);
		}

		public override NSViewController GetViewController(NSPageController pageController, string identifier)
		{
			return new PageRenderer();
		}

		public override void PrepareViewController(NSPageController pageController, NSViewController viewController,
			NSObject targetObject)
		{
			var pageContainer = targetObject as NSPageContainer;
			var pageRenderer = (viewController as PageRenderer);
			if (pageContainer == null || pageRenderer == null)
				return;
			Page page = pageContainer.Page;
			pageRenderer.SetElement(page);
			Platform.SetRenderer(page, pageRenderer);
		}
	}
}