Share via


IXREffect (Compact 2013)

3/28/2014

This C++ class represents the base class for custom effects, which modify the appearance of visual elements in your application.

Syntax

class IXREffect : public IXRDependencyObject

Inheritance Hierarchy

IXRDependencyObject

    IXREffect

Methods

Method

Description

IXREffect::GetCustomEffect

Retrieves a pointer to the class that applies a custom effect to an object in your application.

IXREffect::SetCustomEffect

Sets the class that applies a custom effect to an object in your application.

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

Effects modify the appearance of UI elements, for example, by blurring an element or adding a drop shadow. Effects alter the individual pixels of a rasterized UI object by using an algorithm to alter how the pixels are displayed.

For more information about the implementation of effects in XAML for Windows Embedded, requirements for creating custom effects, and the Blur and DropShadow effects, see Differences Between Microsoft Silverlight 3 and XAML for Windows Embedded.

To display effects in XAML for Windows Embedded, you must use hardware acceleration to ensure that effects are processed as fast as possible. For more information about hardware acceleration, see Hardware-Accelerated Graphics.

Stub code is provided for a Blur and DropShadow effect in the %_WINCEROOT%\PUBLIC\COMMON\OAK\XamlRuntimeEffects folder. The stub code uses the header files %_WINCEROOT%\PUBLIC\COMMON\OAK\XamlEffects\Blur\inc\BlurEffect.h and %_WINCEROOT%\PUBLIC\COMMON\OAK\XamlEffects\DropShadow\inc\DropShadowEffect.h. These files show how to implement your own effects. They contain static functions to get and set the attributes of the effects. For example, the following example code sets the opacity on the drop shadow effect defined in DropShadowEffect.h:

XRPtr<IXREffect> pEffect;
pRootElement->FindName("CDropShadowEffect", &pEffect);
CHR(CDropShadowEffect::SetOpacity( pEffect, 0.7f);

Note

If you add BlurEffect.h and DropShadowEffect.h to an SDK you create for application developers, you must also include CustomEffectBase.h in your SDK.

The following XAML code will apply a drop shadow effect to a button object:

<Button Content="Button">
    <Button.Effect>
        <DropShadowEffect 
            BlurRadius="20"
            Direction="316" 
            ShadowDepth="20"
            Opacity="0.6" />
    </Button.Effect>
</Button>

The following illustration shows the drop shadow effect applied to the button that appears in front of a rounded rectangle. The drop shadow also appears in front of the rectangle.

Gg159778.4c889329-ab6a-4ea0-ad78-cc68604a47fa(en-us,WinEmbedded.80).jpg

Custom Effects

To use custom effects in XAML or in code for a XAML for Windows Embedded application, you must include the header file which defines the custom effect in the application. To apply the custom effect in XAML, use the same syntax used for DropShadowEffect and BlurEffect XAML elements in Microsoft Silverlight 3.

To apply the custom effect in code, follow the steps below:

  1. Include the header file (.h) for the custom effect library.
  2. Create an instance of the custom effect class.
  3. Create an instance of IXREffect and add the custom effect by using the IXREffect::SetCustomEffect method.
  4. Finally, add the effect to the UI element by calling the IXRUIElement::SetEffect method.

The syntax to use for setting properties on the custom effect depends on the implementation of the effect. For example, if CustomEffectClassName is the name of the custom effect class, you could use the following syntax:

HRESULT CustomEffectClassName::GetPropertyName(IXREffect* pEffect, Type* pValue);
HRESULT CustomEffectClassName::SetPropertyName(IXREffect* pEffect, Type Value);

To query for a custom effect which was parsed and loaded into the C++ visual tree, you could use the following syntax:

XRPtr<IXREffect> pEffect;
pRootElement->FindName("CustomEffectClassName", &pEffect);

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

.NET Framework Equivalent

System.Windows.Media.Effects.Effect

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

Classes for Visual Appearance
IXRUIElement::GetEffect