null_byte0x00
null_byte0x00

Reputation: 77

How do I set the foreground property for the MenuBar (UWP, XML)

This issue is exclusive to the MenuBar. I can set the background property, however, setting others make no change to the UI.

(App.xml)

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        </ResourceDictionary.MergedDictionaries>

        <!--#region Brushes -->

        <!-- Background Brushes -->
        <SolidColorBrush x:Key="Main_ColourBrush" Color="#DC143C"/>
        <SolidColorBrush x:Key="Background1_ColourBrush" Color="#1E1E1E"/>
        <SolidColorBrush x:Key="Background2_ColourBrush" Color="#222"/>
        <SolidColorBrush x:Key="BackgroundSearchBox_ColourBrush" Color="#B2B2B2"/>

        <!-- Foreground Brushes -->
        <SolidColorBrush x:Key="ForegroundSearchBox_ColourBrush" Color="#4C4C4C"/>
        <SolidColorBrush x:Key="ForegroundTextBrush_ColourBrush" Color="#DBDBDB"/>
        <!--#endregion-->

        <!-- Menus -->
        <Style x:Key="MainMenu_MenuBar_Style" TargetType="muxc:MenuBar">
            <Setter Property="Foreground" Value="{StaticResource ForegroundTextBrush_ColourBrush}"/>
            <Setter Property="Background" Value="{StaticResource BackgroundSearchBox_ColourBrush}"/>
            <Setter Property="FontFamily" Value="Calibri"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>

        <!-- Text Block -->
        <Style x:Key="Title_TextBlock_Style" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource ForegroundTextBrush_ColourBrush}"/>
            <Setter Property="FontFamily" Value="Calibri"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style> ...
    </ResourceDictionary>
</Application.Resources>

Everything is working except for the MenuBar code, minus the background property.

<muxc:MenuBar Grid.Column="0" Grid.Row="0"
                  Style="{StaticResource MainMenu_MenuBar_Style}">

I tried creating the style in the tag which yielded the same results

Upvotes: 1

Views: 371

Answers (1)

null_byte0x00
null_byte0x00

Reputation: 77

Not a solution directly, however for my case the fix was to set

<MenuBar RequestedTheme="Dark">

Upvotes: 3

Related Questions