none
Background color when on mouse hover in a WPF menu

    Question

  • HI Everyone! I am very new to WPF. I am creating a top menu for my application. In the 'File' menu, I have only one option at this point. 'Exit". I have the background color as black and the forecolor as white, which is fine. However, when i  hover of 'Exit' When running the app, it becomes transparent and the Exit is no longer readable. What is the best way to make sure Exit is readable when I hover the mouse over it at runtime?


    Thank you!

    Jason Brock

     



    Monday, May 17, 2010 12:24 AM

Answers

  • You can place a Trigger like:

    <Trigger Property="IsMouseOver" Value="True">

         <Setter Property="Background" Value="Blue"/>


    </Trigger

    For complete reference check out msdn for menu control template.

    • Marked as answer by Jason Brock Monday, May 17, 2010 6:23 PM
    Monday, May 17, 2010 5:44 AM

All replies

  • Perhaps you can try to use Trigger to change MenuItem background or foreground to make it readable when MenuItem.IsHighlighted is true.

    Check out the MenuItem ControlTemplate Example at http://msdn.microsoft.com/en-us/library/ms747082(VS.85).aspx 


    William
    Monday, May 17, 2010 1:26 AM
  • You can place a Trigger like:

    <Trigger Property="IsMouseOver" Value="True">

         <Setter Property="Background" Value="Blue"/>


    </Trigger

    For complete reference check out msdn for menu control template.

    • Marked as answer by Jason Brock Monday, May 17, 2010 6:23 PM
    Monday, May 17, 2010 5:44 AM
  • Thanks everyone. I wasn't sure who to mark as answer, but both posts were helpful. I probably should read the entire WPF Unleashed book before trying things out, but i couldn't resist. Anyhow, I got this figured out. Thanks again!

    Aspiring Developer
    Monday, May 17, 2010 6:25 PM