diff options
author | Samantha Houts <samantha@teamredwall.com> | 2016-04-18 09:46:51 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-04-18 09:46:51 -0700 |
commit | 75f112400223ea628ee008d311b7d5d54d98eafe (patch) | |
tree | af859c326a488cb0801fd57fca7bbce0cf0b4ad0 /Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs | |
parent | fc05a57e9dfa5b70e21b08f9c8f839b7986b4698 (diff) | |
download | xamarin-forms-75f112400223ea628ee008d311b7d5d54d98eafe.tar.gz xamarin-forms-75f112400223ea628ee008d311b7d5d54d98eafe.tar.bz2 xamarin-forms-75f112400223ea628ee008d311b7d5d54d98eafe.zip |
BarBackgroundColor and BarTextColor on TabbedPage (#96)
* [Core] Add properties to TabbedPage
* [Controls] Add properties to test page
* [iOS] Added BarBackgroundColor & BarTextColor to TabbedPage
* [A] Added BarBackgroundColor & BarTextColor to TabbedPage
* [UWP] Added BarBackgroundColor & BarTextColor to TabbedPage
* [WinRT] Format file
* [WinRT] Added BarBackgroundColor & BarTextColor to TabbedPage
* [Docs] Updated docs
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs index 33923a49..f1df0813 100644 --- a/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs @@ -3,6 +3,7 @@ using System.Collections.Specialized; using System.ComponentModel; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Animation; namespace Xamarin.Forms.Platform.WinRT @@ -87,6 +88,8 @@ namespace Xamarin.Forms.Platform.WinRT OnPagesChanged(Page.Children, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); UpdateCurrentPage(); + UpdateBarTextColor(); + UpdateBarBackgroundColor(); ((INotifyCollectionChanged)Page.Children).CollectionChanged += OnPagesChanged; element.PropertyChanged += OnElementPropertyChanged; @@ -95,6 +98,22 @@ namespace Xamarin.Forms.Platform.WinRT OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); } + Brush GetBarBackgroundBrush() + { + object defaultColor = Windows.UI.Xaml.Application.Current.Resources["ApplicationPageBackgroundThemeBrush"]; + if (Page.BarBackgroundColor.IsDefault && defaultColor != null) + return (Brush)defaultColor; + return Page.BarBackgroundColor.ToBrush(); + } + + Brush GetBarForegroundBrush() + { + object defaultColor = Windows.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"]; + if (Page.BarTextColor.IsDefault) + return (Brush)defaultColor; + return Page.BarTextColor.ToBrush(); + } + public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { if (_canvas.Children.Count == 0) @@ -153,8 +172,22 @@ namespace Xamarin.Forms.Platform.WinRT void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == "CurrentPage") + if (e.PropertyName == nameof(TabbedPage.CurrentPage)) UpdateCurrentPage(); + else if (e.PropertyName == TabbedPage.BarTextColorProperty.PropertyName) + UpdateBarTextColor(); + else if (e.PropertyName == TabbedPage.BarBackgroundColorProperty.PropertyName) + UpdateBarBackgroundColor(); + } + + void UpdateBarBackgroundColor() + { + _tabs.Background = GetBarBackgroundBrush(); + } + + void UpdateBarTextColor() + { + _tabs.Foreground = GetBarForegroundBrush(); } void UpdateCurrentPage() |