summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP
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.UAP
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.UAP')
-rw-r--r--Xamarin.Forms.Platform.UAP/Resources.xaml8
-rw-r--r--Xamarin.Forms.Platform.UAP/TabbedPageRenderer.cs45
2 files changed, 46 insertions, 7 deletions
diff --git a/Xamarin.Forms.Platform.UAP/Resources.xaml b/Xamarin.Forms.Platform.UAP/Resources.xaml
index bca8797..23753c1 100644
--- a/Xamarin.Forms.Platform.UAP/Resources.xaml
+++ b/Xamarin.Forms.Platform.UAP/Resources.xaml
@@ -238,7 +238,9 @@
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
- <TextBlock Text="{Binding}" Margin="10,0,0,0" VerticalAlignment="Center" Style="{ThemeResource TitleTextBlockStyle}" />
+ <Grid Background="{Binding ToolbarBackground}">
+ <TextBlock Text="{Binding}" Margin="10,0,0,0" VerticalAlignment="Center" Style="{ThemeResource TitleTextBlockStyle}" Foreground="{Binding ToolbarForeground}" />
+ </Grid>
</DataTemplate>
</Setter.Value>
</Setter>
@@ -471,7 +473,7 @@
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
- <TextBlock Text="{Binding Title}" Style="{ThemeResource BodyTextBlockStyle}" />
+ <TextBlock Text="{Binding Title}" Foreground="{Binding ToolbarForeground}" Style="{ThemeResource BodyTextBlockStyle}" />
</DataTemplate>
</Setter.Value>
</Setter>
@@ -616,7 +618,7 @@
<ContentControl.Clip>
<RectangleGeometry x:Name="HeaderClipperGeometry"/>
</ContentControl.Clip>
- <Grid Background="Transparent">
+ <Grid Background="{TemplateBinding ToolbarBackground}">
<PivotHeaderPanel x:Name="StaticHeader" Visibility="Collapsed"/>
<PivotHeaderPanel x:Name="Header">
<PivotHeaderPanel.RenderTransform>
diff --git a/Xamarin.Forms.Platform.UAP/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.UAP/TabbedPageRenderer.cs
index 1f1e15f..cde4071 100644
--- a/Xamarin.Forms.Platform.UAP/TabbedPageRenderer.cs
+++ b/Xamarin.Forms.Platform.UAP/TabbedPageRenderer.cs
@@ -15,7 +15,7 @@ namespace Xamarin.Forms.Platform.UWP
{
Loaded += TabbedPagePresenter_Loaded;
Unloaded += TabbedPagePresenter_Unloaded;
- SizeChanged += (s, e) =>
+ SizeChanged += (s, e) =>
{
if (ActualWidth > 0 && ActualHeight > 0)
{
@@ -44,7 +44,7 @@ namespace Xamarin.Forms.Platform.UWP
bool _showTitle;
VisualElementTracker<Page, Pivot> _tracker;
- public Pivot Control { get; private set; }
+ public FormsPivot Control { get; private set; }
public TabbedPage Element { get; private set; }
@@ -157,7 +157,7 @@ namespace Xamarin.Forms.Platform.UWP
{
if (Control == null)
{
- Control = new FormsPivot { Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["TabbedPageStyle"] };
+ Control = new FormsPivot { Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["TabbedPageStyle"], };
Control.SelectionChanged += OnSelectionChanged;
@@ -170,6 +170,8 @@ namespace Xamarin.Forms.Platform.UWP
Control.DataContext = Element;
OnPagesChanged(Element.Children, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
UpdateCurrentPage();
+ UpdateBarTextColor();
+ UpdateBarBackgroundColor();
((INotifyCollectionChanged)Element.Children).CollectionChanged += OnPagesChanged;
element.PropertyChanged += OnElementPropertyChanged;
@@ -178,6 +180,7 @@ namespace Xamarin.Forms.Platform.UWP
Control.SetValue(AutomationProperties.AutomationIdProperty, element.AutomationId);
}
+
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
}
@@ -201,8 +204,13 @@ namespace Xamarin.Forms.Platform.UWP
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 OnLoaded(object sender, RoutedEventArgs args)
@@ -243,6 +251,32 @@ namespace Xamarin.Forms.Platform.UWP
Element.SendDisappearing();
}
+ Brush GetBarBackgroundBrush()
+ {
+ object defaultColor = Windows.UI.Xaml.Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"];
+ if (Element.BarBackgroundColor.IsDefault && defaultColor != null)
+ return (Brush)defaultColor;
+ return Element.BarBackgroundColor.ToBrush();
+ }
+
+ Brush GetBarForegroundBrush()
+ {
+ object defaultColor = Windows.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"];
+ if (Element.BarTextColor.IsDefault)
+ return (Brush)defaultColor;
+ return Element.BarTextColor.ToBrush();
+ }
+
+ void UpdateBarBackgroundColor()
+ {
+ Control.ToolbarBackground = GetBarBackgroundBrush();
+ }
+
+ void UpdateBarTextColor()
+ {
+ Control.ToolbarForeground = GetBarForegroundBrush();
+ }
+
void UpdateBarVisibility()
{
(Control as FormsPivot).ToolbarVisibility = _showTitle ? Visibility.Visible : Visibility.Collapsed;
@@ -255,6 +289,9 @@ namespace Xamarin.Forms.Platform.UWP
var nav = page as NavigationPage;
((ITitleProvider)this).ShowTitle = nav != null;
+ UpdateBarTextColor();
+ UpdateBarBackgroundColor();
+
if (page == null)
return;