Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to style the MenuBarItem Flyout #1035

Closed
ghost opened this issue Jul 11, 2019 · 6 comments
Closed

Unable to style the MenuBarItem Flyout #1035

ghost opened this issue Jul 11, 2019 · 6 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jul 11, 2019

There appears to be no way to style the flyout which appears in a menu bar item. In WPF the Popup was declared in XAML allowing us to make cutom changes to the flyout. Currently the menu flyout is created in code. I tried making a generic MenuFlyoutPresenter style but it isnt getting picked up. Perhaps the code could check if the named ContentButton has a flyout and use that. or failing that the MenuBarItem needs a MenuFlyoutStyle DP?

@jevansaks
Copy link
Member

@YuliKl thinks there might be a way to do this, but if it's not straightforward then a new property on MenuBar & MenuBarItem for the style seems fine.

@YuliKl
Copy link

YuliKl commented Jul 11, 2019

@jordui
I was able to modify the style of MenuBarItem's flyout by placing an implicit style in my App.xaml resources.

<Style TargetType="MenuFlyoutPresenter">
    <Setter Property="Background" Value="Red"/>
</Style>

This had the effect of coloring the backgrounds of all MenuBarItems and all MenuFlyouts in my app.

Can you tell us more about your scenario? Are you trying to style the Flyout of a single MenuBarItem, or all flyouts in a MenuBar? What aspects of the flyout do you need to style?

@ghost
Copy link
Author

ghost commented Jul 12, 2019

@YuliKl Ah yes you're right, I put the implicit style into my App.xaml and it worked. I thought it would work implicitly in my local usercontrol xaml resources (I also tried inside the MenuBarItem overridden Style.Resources).

I am currently working with a customized version of the 19H1 Win32 XamlIslands sample using cppwinrt and mux as we need to use win32 for our app (at least for now). We have our own colour scheme manager so everything will need to be styled for most controls; the background colour and padding etc. That's not to say we couldn't consider ThemeResources though.

@YuliKl
Copy link

YuliKl commented Jul 17, 2019

@jordui, sounds like your issue is resolved so I'll go ahead and close it. Please reopen if I'm misunderstanding.

@YuliKl YuliKl closed this as completed Jul 17, 2019
@MarkIngramUK
Copy link

@YuliKl is it intentional that styling the flyout only works globally (via App.xaml) as opposed to locally in MyUserControl.xaml? For reference, we're using XAML Islands in Win32, so in theory we might want to have the ability to style menus differently depending on what window or dialog they appear on.

@YuliKl
Copy link

YuliKl commented Jul 18, 2019

@YuliKl is it intentional that styling the flyout only works globally (via App.xaml) as opposed to locally in MyUserControl.xaml? For reference, we're using XAML Islands in Win32, so in theory we might want to have the ability to style menus differently depending on what window or dialog they appear on.

I definitely would not call this intentional. While I didn't try adding the style to a user control, I did try making it a resource of the Page and more specific components. @MikeHillberg, any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants