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

The child UIElement within the shadow.

public UIElement? Child { get; set; }

Property Value

UIElement

Direction

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

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

Indicates 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

An enumerator for logical child elements of this element.

protected override IEnumerator LogicalChildren { get; }

Property Value

IEnumerator

RenderMode

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

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

The resolved Thickness of the shadow.

public Thickness ShadowThickness { get; }

Property Value

Thickness

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 visual child elements within this element.

protected override int VisualChildrenCount { get; }

Property Value

int:

The number of visual child elements for this element.

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

GetVisualChild(int)

Overrides GetVisualChild(int), and returns a child at the specified index from a collection of child elements.

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

The zero-based index of the requested child element in the collection.

Returns

Visual:

The requested child element. This should not return null; if the provided index is out of range, an exception is thrown.

HitTestCore(PointHitTestParameters)

Implements HitTestCore(PointHitTestParameters) to supply base element hit testing behavior (returning HitTestResult).

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

Describes the hit test to perform, including the initial hit point.

Returns

HitTestResult:

Results of the test, including the evaluated point.

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)

When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.

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

The drawing instructions for a specific element. This context is provided to the layout system.

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

Defines the Direction property.

public static readonly DependencyProperty DirectionProperty

ElevationProperty

Defines the Elevation property.

public static readonly DependencyProperty ElevationProperty

IsShadowEnabledProperty

Defines the IsShadowEnabled property.

public static readonly DependencyProperty IsShadowEnabledProperty

RenderModeProperty

Defines the RenderMode property.

public static readonly DependencyProperty RenderModeProperty

ShadowOpacityProperty

Defines the ShadowOpacity property.

public static readonly DependencyProperty ShadowOpacityProperty

ShadowThicknessProperty

Defines the ShadowThickness property.

public static readonly DependencyProperty ShadowThicknessProperty

Extension Methods