Reputation: 181
A lot of programs display a little sentence of information in a label in a status bar when you hover over an control to tell you what it will do if you click it and then it resets the text when the mouse leaves its area. One example is PaintShop Pro X4.
I want to do this in my application. I could of course easily do it by changing the content of the label in a status bar using the mouse enter event and then empty it on the mouse leave event like I have done in some of my previous programs but that means I have to create those 2 event handlers for every control that I want to have display its information in the status bar (I could use one handler for the reset and have all controls use it though) but I have a very large number of controls for this. Is there a better way I could do this without using any C# or event handlers? Could I do it in XAML, sort of like the boolean to visibility converter but one that just sets text to something because I do not really want to create loads of event handlers for controls that I may not even use for anything (like group boxes, I will naver use them in code but I want a status information for it)? Thank you.
Upvotes: 2
Views: 2905
Reputation: 69979
You can use the UIElement.IsMouseOver
property in a Trigger
to do what you want. Try something like this:
<TextBlock>
<TextBlock.Style>
<Style>
<Setter Property="Text" Value="Normal text" />
<Style.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Text" Value="Mouse over text" />
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Upvotes: 2