summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT.Tablet
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-04-18 16:46:51 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-04-18 16:46:51 (GMT)
commit75f112400223ea628ee008d311b7d5d54d98eafe (patch)
treeaf859c326a488cb0801fd57fca7bbce0cf0b4ad0 /Xamarin.Forms.Platform.WinRT.Tablet
parentfc05a57e9dfa5b70e21b08f9c8f839b7986b4698 (diff)
downloadxamarin-forms-75f112400223ea628ee008d311b7d5d54d98eafe.zip
xamarin-forms-75f112400223ea628ee008d311b7d5d54d98eafe.tar.gz
xamarin-forms-75f112400223ea628ee008d311b7d5d54d98eafe.tar.bz2
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')
-rw-r--r--Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs35
-rw-r--r--Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml4
-rw-r--r--Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs16
3 files changed, 52 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs
index 33923a4..f1df081 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()
diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml b/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml
index 51b9e1d..cfd5125 100644
--- a/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml
+++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml
@@ -250,7 +250,7 @@
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
- <StackPanel Orientation="Horizontal" Margin="0,11,0,0" />
+ <StackPanel Orientation="Horizontal" Margin="0,11,0,0" Background="{TemplateBinding ToolbarBackground}" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
@@ -261,7 +261,7 @@
<StackPanel VerticalAlignment="Bottom">
<Image DataContext="{Binding Icon, Converter={StaticResource ImageConverter}}" Source="{Binding Value}" HorizontalAlignment="Left" />
<TextBlock Margin="0,15,0,15" Text="{Binding Title, Converter={StaticResource UpperConverter}}"
- Style="{ThemeResource CaptionTextBlockStyle}" FontWeight="SemiBold" Foreground="{ThemeResource AppBarItemForegroundThemeBrush}" HorizontalAlignment="Left" />
+ Style="{ThemeResource CaptionTextBlockStyle}" FontWeight="SemiBold" Foreground="{TemplateBinding ToolbarForeground}" HorizontalAlignment="Left" />
</StackPanel>
</local:TabButton>
</DataTemplate>
diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs b/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs
index d98a27a..0848772 100644
--- a/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs
+++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs
@@ -1,6 +1,7 @@
´╗┐using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Media;
namespace Xamarin.Forms.Platform.WinRT
{
@@ -46,5 +47,20 @@ namespace Xamarin.Forms.Platform.WinRT
public class TabsControl
: ItemsControl
{
+
+ public static readonly DependencyProperty ToolbarForegroundProperty = DependencyProperty.Register(nameof(ToolbarForeground), typeof(Brush), typeof(TabsControl), new PropertyMetadata(default(Brush)));
+ public static readonly DependencyProperty ToolbarBackgroundProperty = DependencyProperty.Register(nameof(ToolbarBackground), typeof(Brush), typeof(TabsControl), new PropertyMetadata(default(Brush)));
+
+ public Brush ToolbarBackground
+ {
+ get { return (Brush)GetValue(ToolbarBackgroundProperty); }
+ set { SetValue(ToolbarBackgroundProperty, value); }
+ }
+
+ public Brush ToolbarForeground
+ {
+ get { return (Brush)GetValue(ToolbarForegroundProperty); }
+ set { SetValue(ToolbarForegroundProperty, value); }
+ }
}
} \ No newline at end of file