Partager via


IXRToolTip (Compact 2013)

3/28/2014

This C++ class represents a control that creates a small pop-up window that displays information for a UI element.

Syntax

class IXRToolTip : public IXRContentControl

Inheritance Hierarchy

IXRDependencyObject

    IXRUIElement

        IXRFrameworkElement

            IXRControl

                IXRContentControl

                    IXRToolTip

Methods

Method

Description

IXRToolTip::AddClosedEventHandler

Attaches a delegate to the Closed event handler for this tooltip. When the tooltip raises the Closed event, this delegate is invoked.

IXRToolTip::AddOpenedEventHandler

Attaches a delegate to the Opened event for this tooltip. When the tooltip raises the Opened event, this delegate is invoked.

IXRToolTip::GetHorizontalOffset

Retrieves the horizontal distance between the target origin and the pop-up alignment point.

IXRToolTip::GetIsOpen

Retrieves a value that indicates whether this tooltip is visible.

IXRToolTip::GetPlacement

Not supported in XAML for Windows Embedded.

IXRToolTip::GetPlacementTarget

Not supported in XAML for Windows Embedded.

IXRToolTip::GetVerticalOffset

Retrieves the vertical distance between the target origin and the pop-up alignment point.

IXRToolTip::RemoveClosedEventHandler

Removes a delegate from the Closed event for this tooltip.

IXRToolTip::RemoveOpenedEventHandler

Removes a delegate from the Opened event for this tooltip.

IXRToolTip::SetHorizontalOffset

Sets the horizontal distance between the target origin and the pop-up alignment point.

IXRToolTip::SetIsOpen

Sets a value that indicates whether this tooltip is visible.

IXRToolTip::SetPlacement

Not supported in XAML for Windows Embedded.

IXRToolTip::SetPlacementTarget

Not supported in XAML for Windows Embedded.

IXRToolTip::SetVerticalOffset

Sets the vertical distance between the target origin and the pop-up alignment point.

Thread Safety

Members of this class are thread safe if you previously called IXRApplication::CreateHostFromXaml and supplied it with an XRWindowCreateParams structure that has AllowsMultipleThreadAccess set to true.

Remarks

You use a tooltip control to provide information to the user, such as tips that help users understand unknown or unfamiliar objects that are not described directly in the UI. For example, you can use a tooltip to provide a label for an IXRButton control. A tooltip displays the content specified in the inherited method IXRContentControl::SetContent. Its content can vary from a simple text string to more complex content, such as an IXRImage object or an IXRStackPanel object with embedded text and images. The content of a tooltip cannot receive the focus.

You can define the position and behavior of the tooltip by using the methods of the IXRToolTip class.

When you create a class instance, use an IXRToolTipPtr smart pointer instead of a raw interface pointer. For more information, see XRPtr<Interface>.

You can also define a tooltip in Microsoft Silverlight 3 XAML. For information about the differences between XAML in XAML for Windows Embedded and Silverlight 3, see Differences Between Microsoft Silverlight 3 and XAML for Windows Embedded. For more information about how to define this element in the source XAML for your application, see the ToolTip Class on MSDN.

Example

The following example code creates a tooltip for a control that displays the text specified in the pText input parameter.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include <windows.h>
#include <XamlRuntime.h>
#include <XRPtr.h>


void AddToolTip(IXRControl* pControl, WCHAR* pText)
{
IXRToolTipPtr pToolTip;
float hzOffset = 10;
float vtOffset = 20;

XRValue xrValue;
xrValue.vType = VTYPE_READONLY_STRING;
xrValue.pReadOnlyStringVal = pText;

pToolTip->SetHorizontalOffset(hzOffset);
pToolTip->SetVerticalOffset(vtOffset);
pToolTip->SetContent(&xrValue);

pControl->SetAttachedProperty(L"ToolTipService.ToolTip", pToolTip);

}

To run this sample code, you must already have a control derived from IXRControl for which you want to create a tooltip. This control should already exist in the visual tree.

.NET Framework Equivalent

System.Windows.Controls.ToolTip

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

Classes for UI Element Management