✅ How to style menu bar??? avalonia
I have figured out how to style the menu bar itself, and style the items in the menu bar, however, I cannot figure out how to style the parts that are white. I have also tried to style the pointerover portion of the MenuItem when the user hovers over the menu, but it's not working either. It's supposed to have a charcoal background, blue font no matter what it happening with it.
I have also tried giving a Classes name to the separator and styling it, but that changed nothing as well. Thanks in advance.
26 Replies
I'm even trying to style the MenuItem.menuItem:pointerover as well for the main display of the menu when a user hovers over Help, and it's not working either so I'm not sure what I'm doing wrong with trying to style the hover effects, and the pop out menu
Try and play with negative margin or negative padding
Like negative numbers
to get rid of the white space?
Yes
Often something like that does the trick
I don't know it'll fix your problem
doing a margin of -5 on the innerMenuItem got rid of the white space. Thank you for that. So now, what about styling the hover effects? I've tried all sorts of everything I can find on google, stackoverflow, and the docs, but nothing seems to be working. When I hover over the word Help on the menu bar, the text turns black and the background turns a darker shade, but I'd like for the background to be transparent and the foreground to be light blue
Not sure about that sorry 😦
no problem 🙂 thank you
right. As of now, this is how my menu bar reacts. I need it to remain the same color scheme regardless. Charcoal background, lightblue font
omg you're a life savor. 2 things.
1. How can I style the border of the popup window? Right now it's like a white, but I'd like to make it lightblue as well
2. What is the link you found this styling at? I have scowered google and couldn't find it
1. I would need some mock code to check that, because 2.
2. No link, rather with rider you can usually see attached parts via an Attribute like this
Sometimes they don't include subsequent item tags, for those cases I run some test code and run Avalonia's DevTools (When the window is in the foreground hit F12 and you can step through the tree, then target specific things
I think you can target the popup border with e.g.:
that looks like it can work
Just an addition to this:
The logical tree has less items while the visual tree is much more verbose and shows almost everything, selecting a specific control in the logical tree, then navigating to the visual tree tab will start you off at that object in the tree (saves some time)
this worked perfectly!
I don't know if you can notice it or not, but so far everything is great. Just one nit pick part. When I hover over Help, it stays the color scheme, but when I click it for the popup menu, and move my mouse away from the word help, it turns back black....I have zero idea what "part" that is
When opening popup it looks to have the following pseudoclasses
:selected
:open
so would it be
MenuItem:selected
or MenuItem:selected /template/ ContentPresenter#PART_Popup
?
I got it with this 😄
Thank you so much for you guys help 😄 ❤️Nicee!
one last question and it's something I've just noticed. In the top of each style file, it has
what does that
Design.PreviewWith
supposed to do?because I've honestly just surpassed it altogether
and as a side note, can I just say this is really starting to feel like a lot of css for a website xD My home page for my application's style file has 173 lines with spaces 😮💨
its for the avalonia previewer to set up a design-time preview (with specific settings like width = x and stuff)
its used as an example of what a specific thing is intended to look like
so I can remove it from the file altogether? or should I use it?
eg. you have a style that adds a rainbow background to a button when its class is "Rainbow" then the code would be like: <Design.PreviewWith><Button Classes="Rainbow"/></Design.PreviewWith>
you can remove it
ok cool. again, thanks for all you guys help ❤️