Skip to end of metadata
Go to start of metadata

Remarks

ContentReflector is inherited from ISContentControl, which means that it can contain a single object of any types, such as a string, an image, or a panel. For more information about this content model, see Content Model Overview.

ContentReflector has a unique fundamental layouting concept. The structure is basically divided into two areas which are ContentElement and ReflectionElement. By default, each area has equal size determined by the ContentHeight and ContentWidth property. The default values for these properties are Double.NaN.

Using these default settings, you need to set the content reflector's height twice as large as its content when the ReflectionPosition is set to Top or Bottom, and content reflector’s width twice as large as its content when the ReflectionPosition is set to Left or Right.

The following examples show how to use ContentReflector with various ReflectionPosition.

XAML

XAML

Working with ReflectionPosition Property

ContentReflector has a unique fundamental layouting concept. The structure is basically divided into two areas which are ContentElement and ReflectionElement. By default, each area has equal size determined by the ContentHeight and ContentWidth property. The default values for these properties are Double.NaN.

Using these default settings, you need to set the content reflector's height twice as large as its content when the ReflectionPosition is set to Top or Bottom, and content reflector’s width twice as large as its content when the ReflectionPosition is set to Left or Right.

Working with ReflectionSource Property

By default, ContentReflector generates the reflection image based on the specified content. You can use any data types as the content to be reflected by the ContentReflector. However, if you’re using an Image as its content, it is recommended to use ReflectionSource to improve the performance. By providing ReflectionSource, the control will use the provided image instead of generating the reflection image.

If you are using non-image content type and having performance issue, you may want to set the AutoRefresh property to false. When set to true, this property enables ContentReflector to re-generate the reflection image whenever the content layout is updated, for instance, due to changes in the content such as text input, resizing, and visual states change.

The following example shows how to use ReflectionSource to improve the performance by skipping the reflection process.

XAML

Definition

public class ContentReflector : ISContentControl

Summary

The following table summarizes the members exposed in this class.

Public Constructors

ContentReflector Constructor()Initializes a new instance of the ContentReflector class.

Public Properties

AutoRefreshGets or sets a value that determines whether the reflection is automatically refresh.
BackgroundNot applicable.
BorderBrushNot applicable.
BorderThicknessNot applicable.
ContentElementGets the content element.
ContentHeightGets or sets the content height.
ContentWidthGets or sets the content width.
CornerRadiusNot applicable.
EnableReflectionGets or sets a value that determine whether reflection is enabled.
ReflectionBrushGets or sets the bottom reflection brush.
ReflectionElementGets the reflection element.
ReflectionImageGets the reflection image element.
ReflectionPositionGets or sets a value that determine the position of the reflection.
ReflectionSourceGets or sets the image source used for the reflection. When specified, the control will use the given image source for the reflection instead of capturing the image from its content.
ReflectionVisibilityGets or sets a value that determine the visibility of the reflection.
RootElementGets the root element.
TargetReflectionGets the target element that will be reflected to the reflection area.

Protected Properties

ProductProduct Info.

Fields

AutoRefreshPropertyIdentifies the AutoRefresh dependency property.
ContentHeightPropertyIdentifies the ContentHeight dependency property.
ContentWidthPropertyIdentifies the ContentWidth dependency property.
EnableReflectionPropertyIdentifies the EnableReflection dependency property.
ReflectionBrushPropertyIdentifies the ReflectionBrush dependency property.
ReflectionChangedEventIdentifies the ReflectionChanged routed event.
ReflectionPositionPropertyIdentifies the ReflectionPosition dependency property.
ReflectionSourcePropertyIdentifies the ReflectionSource dependency property.
ReflectionVisibilityPropertyIdentifies the ReflectionVisibility dependency property.

Public Methods

GetReflectionBitmap()Gets the reflection bitmap from the specified content.
InitializeTemplates()Initializes control templates.
OnApplyTemplate()Builds the visual tree for the ContentReflector when a new template is applied.
RefreshReflectionImage()Refresh the reflection image.
RefreshReflectionPosition()Refresh the reflection position using the latest configuration.
SetReflectionSource(ImageSource)Sets the reflection source to use the specified image instead of capturing the bitmap from content.
SetTargetReflection(UIElement)Sets the target element that going to be reflected in the reflection area.

Protected Methods

OnContentChanged(object, object)Called when the value of the Content property changes.

Events

ReflectionChangedOccurs when the current transition has completed.

Public Constructors

public ContentReflector()

Initializes a new instance of the ContentReflector class.

Public Properties

public bool AutoRefresh { get; set; }

Gets or sets a value that determines whether the reflection is automatically refresh.

public Brush Background { get; set; }

Not applicable.

public Brush BorderBrush { get; set; }

Not applicable.

public Thickness BorderThickness { get; set; }

Not applicable.

public Grid ContentElement { get; }

Gets the content element.

public double ContentHeight { get; set; }

Gets or sets the content height.

public double ContentWidth { get; set; }

Gets or sets the content width.

public CornerRadius CornerRadius { get; set; }

Not applicable.

public bool EnableReflection { get; set; }

Gets or sets a value that determine whether reflection is enabled.

public Brush ReflectionBrush { get; set; }

Gets or sets the bottom reflection brush.

public Grid ReflectionElement { get; }

Gets the reflection element.

public Grid ReflectionImage { get; }

Gets the reflection image element.

public Dock ReflectionPosition { get; set; }

Gets or sets a value that determine the position of the reflection.

public ImageSource ReflectionSource { get; set; }

Gets or sets the image source used for the reflection. When specified, the control will use the given image source for the reflection instead of capturing the image from its content.

public Visibility ReflectionVisibility { get; set; }

Gets or sets a value that determine the visibility of the reflection.

public Grid RootElement { get; }

Gets the root element.

public UIElement TargetReflection { get; }

Gets the target element that will be reflected to the reflection area.

Remarks

If this property has a value which set-able from SetTargetReflection() method, the reflector will use this target element instead of the original content element as the source to be reflected in the reflection area.

 

Protected Properties

protected ProductInfo Product { get; }

Product Info.

Fields

public static readonly DependencyProperty AutoRefreshProperty

Identifies the AutoRefresh dependency property.

public static readonly DependencyProperty ContentHeightProperty

Identifies the ContentHeight dependency property.

public static readonly DependencyProperty ContentWidthProperty

Identifies the ContentWidth dependency property.

public static readonly DependencyProperty EnableReflectionProperty

Identifies the EnableReflection dependency property.

public static readonly DependencyProperty ReflectionBrushProperty

Identifies the ReflectionBrush dependency property.

public static readonly RoutedEvent ReflectionChangedEvent

Identifies the ReflectionChanged routed event.

public static readonly DependencyProperty ReflectionPositionProperty

Identifies the ReflectionPosition dependency property.

public static readonly DependencyProperty ReflectionSourceProperty

Identifies the ReflectionSource dependency property.

public static readonly DependencyProperty ReflectionVisibilityProperty

Identifies the ReflectionVisibility dependency property.

Public Methods

public WriteableBitmap GetReflectionBitmap()

Gets the reflection bitmap from the specified content.

Return Types

Reflection bitmap from the specified content.

 

public void InitializeTemplates()

Initializes control templates.

public void OnApplyTemplate()

Builds the visual tree for the ContentReflector when a new template is applied.

public void RefreshReflectionImage()

Refresh the reflection image.

public void RefreshReflectionPosition()

Refresh the reflection position using the latest configuration.

public void SetReflectionSource(ImageSource source)

Sets the reflection source to use the specified image instead of capturing the bitmap from content.

Parameters

source 

 

public void SetTargetReflection(UIElement element)

Sets the target element that going to be reflected in the reflection area.

Remarks

If this property has a value which set-able from SetTargetReflection() method, the reflector will use this target element instead of the original content element as the source to be reflected in the reflection area.

Parameters

elementTarget element that going to be reflected in the reflection area.

 

Protected Methods

protected void OnContentChanged(object oldContent, object newContent)

Called when the value of the Content property changes.

Parameters

oldContentThe old value of the Content property.
newContentThe new value of the Content property.

 

Events

public event ISRoutedEventHandler ReflectionChanged

Occurs when the current transition has completed.

  • No labels