• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

WPF - Menu Triggers and AStyles

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.
0
vamail2
Asked:
vamail2
  • 4
  • 2
1 Solution
 
Snarf0001Commented:
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">
    <TextBox.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=<<my label name>>, Path=IsMouseOver}" Value="True">
                    <Setter Property="Control.Background" Value="Red" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBox.Style>
</TextBox>

Open in new window

0
 
vamail2Author Commented:
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)?
0
 
vamail2Author Commented:
Awesome.  Thanks.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Snarf0001Commented:
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.
0
 
vamail2Author Commented:
*whoops* I made a mistake.  I meant to close this on snarf's comments not mine
0
 
vamail2Author Commented:
How do I fix this and properly assign points and close based on Snarf's ccomments
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now