How to change the bacground and text color of MenuFlyoutItem?

Dani_S 3,786 Reputation points
2024-09-25T14:36:05.62+00:00

Hi,

How to change the bacground and text color of MenuFlyoutItem?

<FlyoutBase.ContextFlyout >

 <MenuFlyout  >

     <MenuFlyoutItem Text="Load external configurations" 

         Command="{Binding BindingContext.ExternalConfigurationCommand, Source={x:Reference loadExteranlConfigurationButton}}"/>

         <MenuFlyoutItem Text="Load external logo"

         Command="{Binding BindingContext.ExternalLogoCommand, Source={x:Reference loadExteranlConfigurationButton}}"/>

     </MenuFlyout>

</FlyoutBase.ContextFlyout>

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,593 questions
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,386 Reputation points Microsoft Vendor
    2024-10-02T06:50:06.4333333+00:00

    Hello,

    Please open App.xaml in Platforms/Windows folder, then add the following to change the background:

    XML

    <maui:MauiWinUIApplication.Resources>
    <SolidColorBrush x:Key="MenuFlyoutItemBackground">Blue</SolidColorBrush>
    </maui:MauiWinUIApplication.Resources>
    

    About the TextColor, you are not able to set it for now, because there is a known issue on WinUI3. Please refer to Setting Foreground on MenuBarItem doesn't work #7070 and menuflyout background incorrect after live color mode change #9241 and wait for their updates.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.