Supporting Other Controls

,

Some controls may benefit from the tilt effect, yet may not necessarily derive from ButtonBase or ListBoxItem. To enable TiltEffect on an alternative UIElement type, such as on context menu items, add the element Type to the TitleEffect’s list of supported types via the TiltEffect.TiltableItems collection.


Tip

As TiltEffect.TiltableItems is a static property and global to your app, where possible populate it from a centralized location such as your App class, rather than in an ad hoc fashion from, for example, your page classes. This can help to reduce duplication, and allows you to manage type registrations in one location.


The following excerpt demonstrates how to add tilt effect support for the Toolkit’s context menu MenuItem class:

public partial class App : Application
{

    public App()
    {
        /* Content omitted for clarity. */

        TiltEffect.TiltableItems.Add(typeof(MenuItem));
    }
//...
}

To enable the tilt effect on MenuItem elements, you must explicitly set the IsTiltEnabled attached property to true, as demonstrated in the following excerpt:

<Border Padding="10" BorderThickness="2" BorderBrush="White">
    <TextBlock Text="tilt effect applied to context menu" />
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu >
            <toolkit:MenuItem Header="item 1"
                toolkit:TiltEffect.IsTiltEnabled="true" />
            <toolkit:MenuItem Header="item 2"
                toolkit:TiltEffect.IsTiltEnabled="true" />
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
</Border>


Note

Regardless of whether the TiltEffect.IsTiltEnabled property is set to true, if the TiltEffect.TiltableItems collection does not contain the element type (or that of its ancestor), the tilt effect is not applied.


Applying the tilt effect to a context menu item causes it to be indented slightly (see Figure 9.22).

Image

FIGURE 9.22 TiltEffect applied to a MenuItem.

Applied judiciously, TiltEffect can subtly enhance your UI, increasing its perceived responsiveness and making it stand out from the crowd.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.4.79