ToolTip control
The tooltip control is often used as a child of some controls, and an informational tip box pops up on the interface when the mouse moves over the specified control. For example, to save space on a form or to increase aesthetics, an indicative pattern is displayed only on the button, and a text hint box explaining the function of the button pops up when the mouse moves over the button pattern.
in the The use of the ToolTip control in a XAML file is as follows:
<tooltip .../>
- or -
<tooltip ...>
<!-- Adding child elements -
</ToolTip>
- or -
<tooltip ...>
<!-- Add a String -
</ToolTip>
The following describes the common properties of the ToolTip control:
- Content property, Gets or sets the contents to display in the ToolTip control, in addition to text information, you can add elements such as pictures.
- The IsEnabled property gets or sets whether the ToolTip control is available when the property value for the True,tooltip control is available. is not available when the property value is false. The default property value is True.
After describing the common properties, take a look at several common events for the ToolTip control:
- The closed event, which fires when the ToolTip control is visible to hidden.
- The opened event that is triggered when the ToolTip control is displayed.
An example is followed to illustrate how the ToolTip control is used .
Create a blank application project with the Windows store named "Tooltipdemo" and add the following code to the grid element of the MainPage.xaml file.
<textblock text= " Please park your mouse over it "fontsize=" margin= "308,309,751,421" >
<ToolTipService.ToolTip>
<tooltip fontsize= ">"
<ToolTip.Content>
ToolTip Prompt Information
</ToolTip.Content>
</ToolTip>
</ToolTipService.ToolTip>
</TextBlock>
A TextBlock text block is added to the above code to display the text message "Please hover your mouse over". Add a TOOLTIPSERVICE.TOOLTIP element to the text block, add a tooltip control inside the element, set the content property value of the ToolTip control to "ToolTip information", and the value of the FontSize property to 20.
Run the program, in the interface will show "please hover over the above" text message, 4-26 is shown. Move the mouse over the text message, and the text message will appear with a tooltip that says "tooltip information", as shown in effect 4-27.
Figure 4-26 The use of the ToolTip control-the use of the ToolTip control when the mouse is not moved to the word 4-27-when you move the mouse over the word
Win10 series: C # App Control Basics