In This Article

ShadowChrome Class

Renders a double-layer shadow effect around its contents.

public class ShadowChrome : FrameworkElement
Inheritance:
object Visual UIElement FrameworkElement object

Constructors

ShadowChrome()

Initializes an instance of the class.

public ShadowChrome()

Properties

Child

Gets or sets the child UIElement within the shadow.

public UIElement Child { get; set; }

Property Value

UIElement:

The child UIElement within the shadow.

Direction

Gets or sets the direction of the shadow, in degrees, where 270 is down, 315 is lower-right, etc.

public double Direction { get; set; }

Property Value

double:

The direction of the shadow, in degrees. The default value is 270, meaning down.

Elevation

Gets or sets the elevation of the shadow, a value from 0 to 24.

public int Elevation { get; set; }

Property Value

int:

The elevation of the shadow, a value from 0 to 24. The default value is 0.

Remarks

Higher elevations render larger shadows. 0 doesn't render a shadow.

IsShadowEnabled

Gets or sets whether the shadow can be rendered by the chrome.

public bool IsShadowEnabled { get; set; }

Property Value

bool:

true if the shadow can be rendered by the chrome; otherwise, false. The default value is true.

Remarks

Set this property to false to prevent the shadow from rendering.

LogicalChildren

Gets an enumerator for logical child elements of this element.

protected override IEnumerator LogicalChildren { get; }

Property Value

IEnumerator:

An enumerator for logical child elements of this element.

RenderMode

Gets or sets the mode to use for rendering the shadow, which determines if pure WPF rendering or shader effect-based rendering is used.

public ShadowChromeRenderMode RenderMode { get; set; }

Property Value

ShadowChromeRenderMode:

A ShadowChromeRenderMode indicating the mode to use for rendering the shadow. The default value is Default, which uses pure WPF rendering and is intended for a rectangular child's shadow.

Remarks

Shader effects are slower and more resource intensive, but should be used when rendering a shadow for a non-rectangular child.

ShadowOpacity

Gets or sets the opacity of the shadow.

public double ShadowOpacity { get; set; }

Property Value

double:

The opacity of the shadow, a value from 0 to 1. The default value is 0.3.

ShadowThickness

Gets the resolved Thickness of the shadow.

public Thickness ShadowThickness { get; }

Property Value

Thickness:

The resolved Thickness of the shadow.

Remarks

When used as a Popup shadow, the popup may wish to increase its size by this amount to ensure the shadow can render.

VisualChildrenCount

Gets the number of child elements for the Visual.

protected override int VisualChildrenCount { get; }

Property Value

int:

The number of child elements.

Methods

ArrangeOverride(Size)

When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class.

protected override Size ArrangeOverride(Size finalSize)
Parameter Type Description
finalSize Size

The final area within the parent that this element should use to arrange itself and its children.

Returns

Size:

The actual size used.

GetShadowThickness(double, int)

Calculates the shadow thickness for the specified direction and elevation.

public static Thickness GetShadowThickness(double direction, int elevation)
Parameter Type Description
direction double

The shadow direction.

elevation int

The shadow elevation.

Returns

Thickness:

The calculated shadow thickness.

GetVisualChild(int)

Returns the specified Visual in the parent VisualCollection.

protected override Visual GetVisualChild(int index)
Parameter Type Description
index int

The index of the visual object in the VisualCollection.

Returns

Visual:

The child in the VisualCollection at the specified index value.

HitTestCore(PointHitTestParameters)

Determines whether a point coordinate value is within the bounds of the visual object.

protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
Parameter Type Description
hitTestParameters PointHitTestParameters

A PointHitTestParameters object that specifies the Point to hit test against.

Returns

HitTestResult:

A HitTestResult that represents the Visual that is returned from a hit test.

MeasureOverride(Size)

When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.

protected override Size MeasureOverride(Size availableSize)
Parameter Type Description
availableSize Size

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Size:

The size that this element determines it needs during layout, based on its calculations of child element sizes.

OnRender(DrawingContext)

Occurs when the element is rendered.

protected override void OnRender(DrawingContext drawingContext)
Parameter Type Description
drawingContext DrawingContext

The DrawingContext to use.

Fields

DirectionDown

Gets the Direction value for a downward shadow.

public const double DirectionDown = 270

DirectionDownRight

Gets the Direction value for a down-right shadow.

public const double DirectionDownRight = 315

DirectionProperty

Identifies the Direction dependency property. This field is read-only.

public static readonly DependencyProperty DirectionProperty

ElevationProperty

Identifies the Elevation dependency property. This field is read-only.

public static readonly DependencyProperty ElevationProperty

IsShadowEnabledProperty

Identifies the IsShadowEnabled dependency property. This field is read-only.

public static readonly DependencyProperty IsShadowEnabledProperty

RenderModeProperty

Identifies the RenderMode dependency property. This field is read-only.

public static readonly DependencyProperty RenderModeProperty

ShadowOpacityProperty

Identifies the ShadowOpacity dependency property. This field is read-only.

public static readonly DependencyProperty ShadowOpacityProperty

ShadowThicknessProperty

Identifies the ShadowThickness dependency property. This field is read-only.

public static readonly DependencyProperty ShadowThicknessProperty