summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/NavigationPageRendererWinRT.cs
blob: 1539d3aa5a57df83a484871199ff95d55a6b85bc (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace Xamarin.Forms.Platform.WinRT
{
	public partial class NavigationPageRenderer
	{
		void UpdateShowTitle()
		{
			if (Device.Idiom == TargetIdiom.Phone && _parentTabbedPage != null)
				((ITitleProvider)this).ShowTitle = false;
			else
				((ITitleProvider)this).ShowTitle = true;
		}

		static object GetDefaultColor()
		{
			return Windows.UI.Xaml.Application.Current.Resources["ApplicationPageBackgroundThemeBrush"];
		}

		void UpdateBackButton()
		{
			bool showBackButton = PageController.InternalChildren.Count > 1 && NavigationPage.GetHasBackButton(_currentPage);
			_container.ShowBackButton = showBackButton;
		}

		void UpdateToolbarPlacement()
		{
			// Currently we don't support toolbar (CommandBar) placement on Windows 8.1
		}

		void UpdateTitleOnParents()
		{
			if (Element == null)
				return;

			ITitleProvider render = null;
			if (_parentTabbedPage != null)
			{
				render = Platform.GetRenderer(_parentTabbedPage) as ITitleProvider;
				if (render != null)
					render.ShowTitle = (_parentTabbedPage.CurrentPage == Element) && NavigationPage.GetHasNavigationBar(_currentPage);
			}

			if (_parentMasterDetailPage != null)
			{
				render = Platform.GetRenderer(_parentMasterDetailPage) as ITitleProvider;
				if (render != null)
					render.ShowTitle = (_parentMasterDetailPage.Detail == Element) && NavigationPage.GetHasNavigationBar(_currentPage);
			}

			if (render != null && render.ShowTitle)
			{
				render.Title = _currentPage.Title;
				render.BarBackgroundBrush = GetBarBackgroundBrush();
				render.BarForegroundBrush = GetBarForegroundBrush();
			}
		}
	}
}