Gets or sets the width of the rectangle.
Assembly: WindowsBase (in WindowsBase.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
This example shows how to crop an image using CroppedBitmap.
The following Extensible Application Markup Language (XAML) defines resources used within the samples below.
The following example creates an image using a CroppedBitmap as its source.
// Create an Image element. Image croppedImage = new Image(); croppedImage.Width = 200; croppedImage.Margin = new Thickness(5); // Create a CroppedBitmap based off of a xaml defined resource. CroppedBitmap cb = new CroppedBitmap( (BitmapSource)this.Resources["masterImage"], new Int32Rect(30, 20, 105, 50)); //select region rect croppedImage.Source = cb; //set image source to cropped
The CroppedBitmap can also be used as the source of another CroppedBitmap, chaining the cropping. Note that the SourceRect uses values that are relative to the source cropped bitmap and not the initial image.
// Create an Image element. Image chainImage = new Image(); chainImage.Width = 200; chainImage.Margin = new Thickness(5); // Create the cropped image based on previous CroppedBitmap. CroppedBitmap chained = new CroppedBitmap(cb, new Int32Rect(30, 0, (int)cb.Width-30, (int)cb.Height)); // Set the image's source. chainImage.Source = chained;
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.