Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Style FormsCommandBar

$
0
0

I have a Xamarin Forms app and in UWP I'd like to alter the colours of the ellipses button and secondary menu. I've been following the advice provided in another forum post (apparently, I'm not allowed to post links):

@MatthewR said:
If you want to change just the command bar's overflow background color you can change the FormsCommandBar style.

Add this style (copied from Xamarin's Source Code) to your app.xaml in your UWP project.
You can then edit the CommandBarOverFlowPresenter's background Color like this:

<Application xmlns:uwp="using:Xamarin.Forms.Platform.UWP"
. . .>
  <Style TargetType="uwp:FormsCommandBar">
  .
  .
  .
  <CommandBarOverflowPresenter x:Name="SecondaryItemsControl"
                               Background="<YourBackgroundColorHere>"
                               IsEnabled="False"
                               IsTabStop="False"
                               Style="{TemplateBinding CommandBarOverflowPresenterStyle}">
      <CommandBarOverflowPresenter.ItemContainerStyle>
          <Style TargetType="FrameworkElement">
              <Setter Property="HorizontalAlignment" Value="Stretch" />
              <Setter Property="Width" Value="NaN" />
          </Style>
      </CommandBarOverflowPresenter.ItemContainerStyle>
      <CommandBarOverflowPresenter.RenderTransform>
          <TranslateTransform x:Name="OverflowContentTransform" />
      </CommandBarOverflowPresenter.RenderTransform>
  </CommandBarOverflowPresenter>
  .
  .
  .
  </Style>
</Application>

I needed to do this to avoid changing action sheets and pickers background colors.

*Note: Make sure not to specify a x:key for the FormsCommandBar style or it won't work.

However, the style is not being applied. I put my style in the App.xaml resource dictionary. I'm using Xamarin Forms 2.5.0.280555.

Am I missing something?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>