Edit

Share via


ImageCropper Class

Definition

The ImageCropper control allows user to crop image freely.

[Windows.UI.Xaml.TemplatePart(Name="PART_LayoutGrid", Type=typeof(Windows.UI.Xaml.Controls.Grid))]
[Windows.UI.Xaml.TemplatePart(Name="PART_ImageCanvas", Type=typeof(Windows.UI.Xaml.Controls.Canvas))]
[Windows.UI.Xaml.TemplatePart(Name="PART_SourceImage", Type=typeof(Windows.UI.Xaml.Controls.Image))]
[Windows.UI.Xaml.TemplatePart(Name="PART_MaskAreaPath", Type=typeof(Windows.UI.Xaml.Shapes.Path))]
[Windows.UI.Xaml.TemplatePart(Name="PART_TopThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_BottomThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_LeftThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_RightThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_UpperLeftThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_UpperRightThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_LowerLeftThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
[Windows.UI.Xaml.TemplatePart(Name="PART_LowerRightThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))]
public class ImageCropper : Windows.UI.Xaml.Controls.Control
[<Windows.UI.Xaml.TemplatePart(Name="PART_LayoutGrid", Type=typeof(Windows.UI.Xaml.Controls.Grid))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_ImageCanvas", Type=typeof(Windows.UI.Xaml.Controls.Canvas))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_SourceImage", Type=typeof(Windows.UI.Xaml.Controls.Image))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_MaskAreaPath", Type=typeof(Windows.UI.Xaml.Shapes.Path))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_TopThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_BottomThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_LeftThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_RightThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_UpperLeftThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_UpperRightThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_LowerLeftThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
[<Windows.UI.Xaml.TemplatePart(Name="PART_LowerRightThumb", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.ImageCropperThumb))>]
type ImageCropper = class
    inherit Control
Public Class ImageCropper
Inherits Control
Inheritance
Windows.UI.Xaml.Controls.Control
ImageCropper
Attributes
Windows.UI.Xaml.TemplatePartAttribute

Constructors

ImageCropper()

Initializes a new instance of the ImageCropper class.

Fields

AspectRatioProperty

Identifies the AspectRatio dependency property.

CropShapeProperty

Identifies the CropShape dependency property.

MaskProperty

Identifies the Mask dependency property.

PrimaryThumbStyleProperty

Identifies the PrimaryThumbStyle dependency property.

SecondaryThumbStyleProperty

Identifies the SecondaryThumbStyle dependency property.

SourceProperty

Identifies the Source dependency property.

ThumbPlacementProperty

Identifies the ThumbPlacement dependency property.

Properties

AspectRatio

Gets or sets the aspect ratio of the cropped image, the default value is null. Only works when CropShape = Rectangular.

CroppedRegion

Gets the current cropped region.

CropShape

Gets or sets the shape to use when cropping.

Mask

Gets or sets the mask on the cropped image.

MinCroppedPixelLength

Gets or sets the minimum cropped length(in pixel).

MinSelectedLength

Gets or sets the minimum selectable length.

PrimaryThumbStyle

Gets or sets a value for the style to use for the primary thumbs of the ImageCropper.

SecondaryThumbStyle

Gets or sets a value for the style to use for the secondary thumbs of the ImageCropper.

Source

Gets or sets the source of the cropped image.

ThumbPlacement

Gets or sets a value for thumb placement.

Methods

LoadImageFromFile(StorageFile)

Load an image from a file.

MeasureOverride(Size) Windows.UI.Xaml.Controls.Control.MeasureOverride(Windows.Foundation.Size)
OnApplyTemplate() Windows.UI.Xaml.Controls.Control.OnApplyTemplate
Reset()

Reset the cropped area.

SaveAsync(IRandomAccessStream, BitmapFileFormat, Boolean)

Saves the cropped image to a stream with the specified format.

TrySetCroppedRegion(Rect)

Tries to set a new value for the cropped region, returns true if it succeeded, false if the region is invalid

Applies to