how to change the background color of flyout in uwp?

耗尽温柔 提交于 2021-01-07 03:23:14

问题


I want to set menu flyout background either in c# or xaml.

I want like this

<FlyoutBase.AttachedFlyout>             
     <MenuFlyout x:Name="Flyout">
        <MenuFlyout.Items >
           <MenuFlyoutItem Text="Add Expense" Click="AddExpense_Click"/>
           <MenuFlyoutItem Text="Add Friends" Click="AddFriends_Click"/>
        </MenuFlyout.Items>
     </MenuFlyout>
</FlyoutBase.AttachedFlyout>  

... And this is my xaml code for menu fly-out


回答1:


For your requirement, you could custom MenuFlyoutPresenterStyle like the following

<MenuFlyout x:Name="Flyout">
        <MenuFlyout.MenuFlyoutPresenterStyle>
            <Style TargetType="MenuFlyoutPresenter">
                <Setter Property="Background" Value="Red"/>
            </Style>
        </MenuFlyout.MenuFlyoutPresenterStyle>
        <MenuFlyout.Items >
            <MenuFlyoutItem Text="Add Expense" />
            <MenuFlyoutItem Text="Add Friends" />
        </MenuFlyout.Items>
</MenuFlyout>



回答2:


You have to change the FlyoutPresenterStyle, I think.



来源:https://stackoverflow.com/questions/57519359/how-to-change-the-background-color-of-flyout-in-uwp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!