How do I make a Xamarin UWP Bottom Tabbar and Change the Color on the fly?

B Martin 21 Reputation points
2021-04-05T12:31:14.11+00:00

After much digging, I found a custom renderer that creates a bottom Tabbar on Xamarin Forms Uwp, but since it's based on a style I had to add to the UWP app.Xaml, I have no idea how to change the tabbar background and text colors.

Any Ideas? Or do you have a renderer that will work better?

The Style is at: https://pastebin.com/gyx0a5Bq

The Renderer code:

public class TabbedPageRenderer : Xamarin.Forms.Platform.UWP.TabbedPageRenderer
   {
      protected override void OnElementChanged(VisualElementChangedEventArgs e)
      {
         base.OnElementChanged(e);
         if (Control != null)
            Control.Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["PivotHeaderBottomStyle"];
      }
  }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,287 questions
0 comments No comments
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-04-15T06:04:11.8+00:00

    CustomTabbedPage in Forms project

    <local:Page1 Title="Tab 1" >
            <local:Page1.IconImageSource>
                <FontImageSource  Glyph="&#xf2b9;" Color="Red"/>
            </local:Page1.IconImageSource>
        </local:Page1>
    

    App.xaml in UWP project

    <Grid.RowDefinitions>
             <RowDefinition Height="30"/>
              <RowDefinition Height="20"/>
               </Grid.RowDefinitions>
                   <TextBlock Text="{Binding IconImageSource.Glyph}" FontFamily="ms-appx:///Assets/Font Awesome 5 Free-Solid-900.oft#Font Awesome 5 Free Solid"/>
                  <TextBlock  HorizontalAlignment="Center" Foreground="Red" Grid.Row="1" Text="{Binding Title}"  Style="{ThemeResource BodyTextBlockStyle}"/>
    
    0 comments No comments

13 additional answers

Sort by: Most helpful
  1. Alma Jensen 1 Reputation point
    2021-04-06T02:19:03.577+00:00

    I just did this today, but what I did was to create an effect and then a class with a bindable property. I based what I did on this blog. xamarin-forms-use-bindableproperty-in-effects Something I realized later is that this sample adds the effect only on a property change. Something you can do about that is to add both the effect as you would normally and then to also add the static class as mentioned in the article. In case you haven't done Bindable Properties before you do have to follow a specific naming convention for them to work.

    I'm going to see if I can append more detail here. The comment replies don't leave enough characters to paste in the code samples.

    Here's the effect

        public class EntryScrubberEffect : RoutingEffect
        {
            public EntryScrubberEffect() : base("Xamarin.EntryScrubberEffect")
            {
                Carrier = FShippingCarrier.Unknown;
            }
    
            public EntryScrubberEffect(FShippingCarrier carrier) : base("Xamarin.EntryScrubberEffect")
            {
                Carrier = carrier;
            }
    
            public event ItemScannedEventHandler ItemScanned;
            public void OnItemScanned(Element element, ItemScannedEventArgs args)
                => ItemScanned?.Invoke(element, args);
    
            public FShippingCarrier Carrier { get; set; }
        }
    

    Here's the Bindable static class

    public static class StaticEntryScrubberEffect
    {
        public static BindableProperty CarrierProperty = BindableProperty.CreateAttached(
            "ShipCarrier",
            typeof(FShippingCarrier),
            typeof(StaticEntryScrubberEffect),
            FShippingCarrier.Unknown,
            propertyChanged: OnShipCarrierChanged);
    
        static void OnShipCarrierChanged(BindableObject bindable, object oldValue, object newValue)
        {
            AttachEffect(bindable as Editor, (FShippingCarrier)newValue);
        }
    
        static void AttachEffect(Editor element, FShippingCarrier newValue)
        {
            var effect = element.Effects.FirstOrDefault(x => x is EntryScrubberEffect) as EntryScrubberEffect;
    
            if (effect != null)
            {
                element.Effects.Remove(effect);
            }
    
            element.Effects.Add(new EntryScrubberEffect(newValue));
        }
    
        public static FShippingCarrier GetShipCarrier(BindableObject element)
        {
            return (FShippingCarrier)element.GetValue(CarrierProperty);
        }
    
        public static void SetShipCarrier(BindableObject element, FShippingCarrier value)
        {
            element.SetValue(CarrierProperty, value);
        }
    }
    

    Here's the relavant Xaml

    xmlns:ent="clr-namespace:Semita.Effects" 
    
                                <Editor 
                                    Text="{Binding UserName}"
                                    IsSpellCheckEnabled="False"
                                    IsTextPredictionEnabled="False"
                                    Unfocused="Entry_Unfocused"                                
                                    TextColor="Black" 
                                    VerticalOptions="Center" 
                                    x:Name="UserNameField"
                                    ent:StaticEntryScrubberEffect.Carrier="{Binding ImageColor}">
                                    <Editor.Effects>
                                        <ent:EntryScrubberEffect
                                            ItemScanned="EntryScrubberEffect_ItemScanned"/>
                                    </Editor.Effects>
                                </Editor>
    

    Here's my implmentation off the effect
    [assembly: Xamarin.Forms.ResolutionGroupName("Xamarin")]
    [assembly: Xamarin.Forms.ExportEffect(typeof(EntryScrubberEffectUWP), "EntryScrubberEffect")]
    namespace Semita.UWP
    {
    public class EntryScrubberEffectUWP : PlatformEffect
    {
    FrameworkElement frameworkElement;
    Effects.EntryScrubberEffect effect;
    Action<Element, ItemScannedEventArgs> onItemScanned;

        public EntryScrubberEffectUWP()
        {
        }
    
        protected override void OnAttached()
        {
            frameworkElement = Control == null ? Container : Control;
            effect = (Effects.EntryScrubberEffect)Element?.Effects?.FirstOrDefault(e => e is Effects.EntryScrubberEffect);
            if (effect != null && frameworkElement != null)
            {
                onItemScanned = effect.OnItemScanned;
            }
    
            Control.KeyDown += Control_KeyDown;
            Control.PreviewKeyDown += Control_PreviewKeyDown;
        }
    
        private void Control_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                var control = Control as TextBox;
                if (control == null)
                    return;
    
                onItemScanned(Element, new ItemScannedEventArgs(control.Text));
            }
        }
    
        private void Control_PreviewKeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                var control = Control as TextBox;
                if (control == null)
                    return;
    
                if (AllNumeric(control.Text))
                    control.Text = string.Empty;
                else
                    onItemScanned(Element, new ItemScannedEventArgs(control.Text));
            }
        }
    
        protected override void OnDetached()
        {
            var control = Control as TextBox;
            if (control == null)
                return;
    
            control.PreviewKeyDown -= Control_PreviewKeyDown;
            control.KeyDown -= Control_KeyDown;
        }
    
        public bool AllNumeric(string str)
        {
            try
            {
                foreach (char c in str)
                {
                    if (c < '0' || c > '9')
                        return false;
                }
                return true;
    
            }
            catch
            {
                return false;
            }
        }
    }
    

    }

    Please note that this code isn't complete yet or totally optimized. It's a work in progess that I just started yesterday. I just hope it gives you enough of an idea about how to potentially accomplish what you wanted to do using an effect. A custom renderer with some added bindable properties is also a completely valid way of accomplishing this task as well.


  2. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-04-06T06:00:48.177+00:00

    Hello,

    Welcome to Microsoft Q&A!

    We just need to find out the corresponding control in the style and set Color on it .

    Replace the following style with the original one

       <Style  
                       x:Key="PivotHeaderBottomStyle"  
                       TargetType="Pivot">  
                       <Setter  
                           Property="Margin"  
                           Value="0" />  
                       <Setter  
                           Property="Padding"  
                           Value="0" />  
                       <Setter  
                           Property="Background"  
                           Value="Transparent" />  
                       <Setter  
                           Property="IsTabStop"  
                           Value="False" />  
                       <Setter  
                           Property="ItemsPanel">  
                           <Setter.Value>  
                               <ItemsPanelTemplate>  
                                   <Grid  />  
                               </ItemsPanelTemplate>  
                           </Setter.Value>  
                       </Setter>  
                       <Setter  
                           Property="ItemTemplate">  
                           <Setter.Value>  
                               <DataTemplate>  
                                   <ContentPresenter   
                                       Content="{Binding}"  
                                       ContentTemplate="{ThemeResource ContainedPageTemplate}"  
                                       />  
                               </DataTemplate>  
                           </Setter.Value>  
                       </Setter>  
                       <Setter  
                           Property="HeaderTemplate">  
                           <Setter.Value>  
                               <DataTemplate>  
                                   <Grid>  
                                       <TextBlock Foreground="Red"  
                                       Text="{Binding Title}"  
                                       Style="{ThemeResource BodyTextBlockStyle}"  
                                       />  
                                   </Grid>  
                               </DataTemplate>  
                           </Setter.Value>  
                       </Setter>  
                       <Setter  
                           Property="Template">  
                           <Setter.Value>  
                               <ControlTemplate  
                                   TargetType="Pivot">  
                                   <Grid  
                                       x:Name="RootElement"  
                                       Background="{TemplateBinding Background}"  
                                       HorizontalAlignment="{TemplateBinding HorizontalAlignment}"  
                                       VerticalAlignment="{TemplateBinding VerticalAlignment}">  
                                       <Grid.Resources>  
                                           <Style  
                                               x:Key="BaseContentControlStyle"  TargetType="ContentControl">  
                                         
                                               <Setter  
                                                   Property="FontFamily"  
                                                   Value="XamlAutoFontFamily" />  
                                               <Setter  
                                                   Property="FontWeight"  
                                                   Value="SemiBold" />  
                                               <Setter  
                                                   Property="FontSize"  
                                                   Value="15" />  
                                               <Setter  
                                                   Property="Template">  
                                                   <Setter.Value>  
                                                       <ControlTemplate  
                                                           TargetType="ContentControl">  
                                                           <ContentPresenter  
                                                               ContentTemplate="{TemplateBinding ContentTemplate}"  
                                                               ContentTransitions="{TemplateBinding ContentTransitions}"  
                                                               Content="{TemplateBinding Content}"  
                                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"  
                                                               Margin="{TemplateBinding Padding}"  
                                                               OpticalMarginAlignment="TrimSideBearings"  
                                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />  
                                                       </ControlTemplate>  
                                                   </Setter.Value>  
                                               </Setter>  
                                           </Style>  
                                           <Style  
                                               x:Key="TitleContentControlStyle"  
                                               BasedOn="{StaticResource BaseContentControlStyle}"  
                                               TargetType="ContentControl">  
                                               <Setter  
                                                   Property="FontFamily"  
                                                   Value="{ThemeResource PivotTitleFontFamily}" />  
                                               <Setter  
                                                   Property="FontWeight"  
                                                   Value="{ThemeResource PivotTitleThemeFontWeight}" />  
                                               <Setter  
                                                   Property="FontSize"  
                                                   Value="{ThemeResource PivotTitleFontSize}" />  
                                        
                                           </Style>  
                                       </Grid.Resources>  
                                       <Grid.RowDefinitions>  
                                           <RowDefinition  
                                               Height="Auto" />  
                                           <RowDefinition  
                                               Height="*" />  
                                       </Grid.RowDefinitions>  
                                       <VisualStateManager.VisualStateGroups>  
                                           <VisualStateGroup  
                                               x:Name="Orientation">  
                                               <VisualState  
                                                   x:Name="Portrait">  
                                                   <Storyboard>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="Margin"  
                                                           Storyboard.TargetName="TitleContentControl">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="{ThemeResource PivotPortraitThemePadding}" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                   </Storyboard>  
                                               </VisualState>  
                                               <VisualState  
                                                   x:Name="Landscape">  
                                                   <Storyboard>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="Margin"  
                                                           Storyboard.TargetName="TitleContentControl">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="{ThemeResource PivotLandscapeThemePadding}" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                   </Storyboard>  
                                               </VisualState>  
                                           </VisualStateGroup>  
                                           <VisualStateGroup  
                                               x:Name="NavigationButtonsVisibility">  
                                               <VisualState  
                                                   x:Name="NavigationButtonsHidden" />  
                                               <VisualState  
                                                   x:Name="NavigationButtonsVisible">  
                                                   <Storyboard>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="Opacity"  
                                                           Storyboard.TargetName="NextButton">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="1" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="IsEnabled"  
                                                           Storyboard.TargetName="NextButton">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="True" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="Opacity"  
                                                           Storyboard.TargetName="PreviousButton">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="1" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="IsEnabled"  
                                                           Storyboard.TargetName="PreviousButton">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="True" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                   </Storyboard>  
                                               </VisualState>  
                                           </VisualStateGroup>  
                                           <VisualStateGroup  
                                               x:Name="HeaderStates">  
                                               <VisualState  
                                                   x:Name="HeaderDynamic" />  
                                               <VisualState  
                                                   x:Name="HeaderStatic">  
                                                   <Storyboard>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="Visibility"  
                                                           Storyboard.TargetName="Header">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="Collapsed" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                       <ObjectAnimationUsingKeyFrames  
                                                           Storyboard.TargetProperty="Visibility"  
                                                           Storyboard.TargetName="StaticHeader">  
                                                           <DiscreteObjectKeyFrame  
                                                               KeyTime="0"  
                                                               Value="Visible" />  
                                                       </ObjectAnimationUsingKeyFrames>  
                                                   </Storyboard>  
                                               </VisualState>  
                                           </VisualStateGroup>  
                                       </VisualStateManager.VisualStateGroups>  
                                       <ContentControl  
                                           x:Name="TitleContentControl"  
                                           ContentTemplate="{TemplateBinding TitleTemplate}"  
                                           Content="{TemplateBinding Title}"  
                                           IsTabStop="False"  
                                           Margin="{StaticResource PivotPortraitThemePadding}"  
                                           Style="{StaticResource TitleContentControlStyle}"  
                                           Visibility="Collapsed" />  
                                       <Grid  
                                           Grid.Row="1">  
                                           <Grid.Resources>  
                                               <ControlTemplate  
                                                   x:Key="NextTemplate"  
                                                   TargetType="Button">  
                                                   <Border  
                                                       x:Name="Root"  
                                                       BorderBrush="{ThemeResource SystemControlForegroundTransparentBrush}"  
                                                       BorderThickness="{ThemeResource PivotNavButtonBorderThemeThickness}"  
                                                       Background="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}">  
                                                       <VisualStateManager.VisualStateGroups>  
                                                           <VisualStateGroup  
                                                               x:Name="CommonStates">  
                                                               <VisualState  
                                                                   x:Name="Normal" />  
                                                               <VisualState  
                                                                   x:Name="PointerOver">  
                                                                   <Storyboard>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Background"  
                                                                           Storyboard.TargetName="Root">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Foreground"  
                                                                           Storyboard.TargetName="Arrow">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                   </Storyboard>  
                                                               </VisualState>  
                                                               <VisualState  
                                                                   x:Name="Pressed">  
                                                                   <Storyboard>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Background"  
                                                                           Storyboard.TargetName="Root">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightBaseMediumHighBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Foreground"  
                                                                           Storyboard.TargetName="Arrow">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                   </Storyboard>  
                                                               </VisualState>  
                                                           </VisualStateGroup>  
                                                       </VisualStateManager.VisualStateGroups>  
                                                       <FontIcon  
                                                           x:Name="Arrow"  
                                                           Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}"  
                                                           FontSize="12"  
                                                           FontFamily="{ThemeResource SymbolThemeFontFamily}"  
                                                           Glyph="&#xE0E3;"  
                                                           HorizontalAlignment="Center"  
                                                           MirroredWhenRightToLeft="True"  
                                                           UseLayoutRounding="False"  
                                                           VerticalAlignment="Center" />  
                                                   </Border>  
                                               </ControlTemplate>  
                                               <ControlTemplate  
                                                   x:Key="PreviousTemplate"  
                                                   TargetType="Button">  
                                                   <Border  
                                                       x:Name="Root"  
                                                       BorderBrush="{ThemeResource SystemControlForegroundTransparentBrush}"  
                                                       BorderThickness="{ThemeResource PivotNavButtonBorderThemeThickness}"  
                                                       Background="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}">  
                                                       <VisualStateManager.VisualStateGroups>  
                                                           <VisualStateGroup  
                                                               x:Name="CommonStates">  
                                                               <VisualState  
                                                                   x:Name="Normal" />  
                                                               <VisualState  
                                                                   x:Name="PointerOver">  
                                                                   <Storyboard>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Background"  
                                                                           Storyboard.TargetName="Root">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightBaseMediumBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Foreground"  
                                                                           Storyboard.TargetName="Arrow">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                   </Storyboard>  
                                                               </VisualState>  
                                                               <VisualState  
                                                                   x:Name="Pressed">  
                                                                   <Storyboard>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Background"  
                                                                           Storyboard.TargetName="Root">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightBaseMediumHighBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                       <ObjectAnimationUsingKeyFrames  
                                                                           Storyboard.TargetProperty="Foreground"  
                                                                           Storyboard.TargetName="Arrow">  
                                                                           <DiscreteObjectKeyFrame  
                                                                               KeyTime="0"  
                                                                               Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}" />  
                                                                       </ObjectAnimationUsingKeyFrames>  
                                                                   </Storyboard>  
                                                               </VisualState>  
                                                           </VisualStateGroup>  
                                                       </VisualStateManager.VisualStateGroups>  
                                                       <FontIcon  
                                                           x:Name="Arrow"  
                                                           Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}"  
                                                           FontSize="12"  
                                                           FontFamily="{ThemeResource SymbolThemeFontFamily}"  
                                                           Glyph="&#xE0E2;"  
                                                           HorizontalAlignment="Center"  
                                                           MirroredWhenRightToLeft="True"  
                                                           UseLayoutRounding="False"  
                                                           VerticalAlignment="Center" />  
                                                   </Border>  
                                               </ControlTemplate>  
                                           </Grid.Resources>  
                                           <ScrollViewer  
                                               x:Name="ScrollViewer"  
                                               BringIntoViewOnFocusChange="False"  
                                               HorizontalSnapPointsAlignment="Center"  
                                               HorizontalSnapPointsType="MandatorySingle"  
                                               HorizontalScrollBarVisibility="Hidden"  
                                               Margin="{TemplateBinding Padding}"  
                                               Template="{StaticResource ScrollViewerScrollBarlessTemplate}"  
                                               VerticalSnapPointsType="None"  
                                               VerticalScrollBarVisibility="Disabled"  
                                               VerticalScrollMode="Disabled"  
                                               VerticalContentAlignment="Stretch"  
                                               ZoomMode="Disabled">  
                                               <PivotPanel  
                                                   x:Name="Panel"  
                                                   VerticalAlignment="Stretch">  
                                                   <Grid  
                                                       x:Name="PivotLayoutElement">  
                                                       <Grid.ColumnDefinitions>  
                                                           <ColumnDefinition  
                                                               Width="Auto" />  
                                                           <ColumnDefinition  
                                                               Width="*" />  
                                                           <ColumnDefinition  
                                                               Width="Auto" />  
                                                       </Grid.ColumnDefinitions>  
                                                       <Grid.RowDefinitions>  
                                                           <RowDefinition  
                                                               Height="*" />  
                                                           <RowDefinition  
                                                               Height="Auto" />  
                                                       </Grid.RowDefinitions>  
                                                       <Grid.RenderTransform>  
                                                           <CompositeTransform  
                                                               x:Name="PivotLayoutElementTranslateTransform" />  
                                                       </Grid.RenderTransform>  
                                                       <ContentPresenter  
                                                           Visibility="Collapsed"  
                                                           x:Name="LeftHeaderPresenter"  
                                                           ContentTemplate="{TemplateBinding LeftHeaderTemplate}"  
                                                           Content="{TemplateBinding LeftHeader}"  
                                                           HorizontalAlignment="Stretch"  
                                                           VerticalAlignment="Stretch" />  
                                                       <ContentControl  
                                                           x:Name="HeaderClipper"  
                                                           Grid.Column="1"  
                                                           Grid.Row="1"  
                                                     
                                                           HorizontalContentAlignment="Stretch"  
                                                           UseSystemFocusVisuals="True">  
                                                           <ContentControl.Clip>  
                                                               <RectangleGeometry  
                                                                   x:Name="HeaderClipperGeometry" />  
                                                           </ContentControl.Clip>  
                                                           <Grid  
                                                               Background="Yellow">  
                                                               <PivotHeaderPanel  
                                                                   x:Name="StaticHeader"  
                                                                   Visibility="Collapsed
    

  3. B Martin 21 Reputation points
    2021-04-06T19:03:56.337+00:00

    Talking about some terrible coding, I made a small style for each of my themes that does nothing but override the Tabbar color. Embarrassing, but it works!

     <Style x:Key="PivotHeaderBottomBlackThemeStyle"
                   TargetType="Pivot"
                   BasedOn="{StaticResource PivotHeaderBottomBaseStyle}">
                <Setter Property="Background"
                        Value="Black" />
            </Style>
    
      <Style x:Key="PivotHeaderBottomNavyBlueThemeStyle"
                   TargetType="Pivot"
                   BasedOn="{StaticResource PivotHeaderBottomBaseStyle}">
                <Setter Property="Background"
                        Value="Navy" />
            </Style>
    

    Does anyone know which property in the PivotHeaderBottomStyle up above that I have to override to change the text color on the tabbar? I can't find it.

    0 comments No comments

  4. B Martin 21 Reputation points
    2021-04-06T19:44:18.787+00:00

    Got it! The TextBlock for the tabbar is in the HeaderTemplate, so I had to include that in each of the style overrides. Now, does anyone know how to add FontAwesome Icons to this thing?

        <Style
            x:Key="PivotHeaderBottomPurpleThemeStyle"
            BasedOn="{StaticResource PivotHeaderBottomBaseStyle}"
            TargetType="Pivot">
            <Setter Property="Background" Value="#330054" />
    
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <TextBlock
                                Foreground="MistyRose"
                                Style="{ThemeResource BodyTextBlockStyle}"
                                Text="{Binding Title}" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
    
        </Style>