WPF - Menu Triggers and AStyles

Posted on 2011-10-26
Last Modified: 2012-05-12
I was looking for the best way through XAML to change the background color of a textbox when I am hovering over a particular menu item in the mainwindow (and then it should return back to normal).  I realize this is simple but I wasn't getting it to work.
Question by:vamail2
    LVL 22

    Expert Comment

    I would use a style trigger on the textbox, bound to the IsMouseOver property of the desired menu item.
    <TextBox Text="my text here" Width="150">
                    <DataTrigger Binding="{Binding ElementName=<<my label name>>, Path=IsMouseOver}" Value="True">
                        <Setter Property="Control.Background" Value="Red" />

    Open in new window


    Accepted Solution

    Awesome, thank you Snarf.   I'll get this thing one day... is there any particular book or tutorial website you think is excellent (from begin to master)?

    Author Closing Comment

    Awesome.  Thanks.
    LVL 22

    Expert Comment

    No problem.  When I started with WPF I used "WPF Programmer's Reference" from wrox.
    Gives a really good starting point and a lot of detailed features.
    The Microsoft documentation is atrocious, once you get comfortable with WPF in general, other non-ms examples online are very helpful.

    It can be a bit tricky off the start, since there's half a million different ways to do the same thing, but all I can say is the more you do it, the more intuitive it becomes.

    By FAR my favorite proejcts to work on now are WPF.

    Author Comment

    *whoops* I made a mistake.  I meant to close this on snarf's comments not mine

    Author Comment

    How do I fix this and properly assign points and close based on Snarf's ccomments

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now