1 'This is a list of commonly used namespaces for a pane.
4 Imports System
.Windows
.Documents
5 Imports System
.Windows
.Controls
6 Imports System
.Windows
.Navigation
7 Imports System
.Windows
.Input
8 Imports System
.Windows
.Media
9 Imports System
.Windows
.Media
.Imaging
11 Namespace ImageElementExample
13 Partial Class CroppedImageExample
21 Private Sub PageLoaded(ByVal sender
As Object, ByVal args
As RoutedEventArgs
)
22 ' Create an Image element.
23 Dim croppedImage
As New Image()
24 croppedImage
.Width
= 200
25 croppedImage
.Margin
= New Thickness(5)
27 ' Create a CroppedBitmap based off of a xaml defined resource.
28 Dim cb
As New CroppedBitmap(CType(Me.Resources("masterImage"), BitmapSource
), New Int32Rect(30, 20, 105, 50))
30 croppedImage
.Source
= cb
'set image source to cropped
32 Grid
.SetColumn(croppedImage
, 1)
33 Grid
.SetRow(croppedImage
, 1)
34 croppedGrid
.Children
.Add(croppedImage
)
36 ' Create an Image element.
37 Dim chainImage
As New Image()
38 chainImage
.Width
= 200
39 chainImage
.Margin
= New Thickness(5)
41 ' Create the cropped image based on previous CroppedBitmap.
42 Dim chained
As New CroppedBitmap(cb
, New Int32Rect(30, 0, CType(cb
.Width
, Integer) - 30, CType(cb
.Height
, Integer)))
43 ' Set the image's source.
44 chainImage
.Source
= chained
45 ' Add Image to the UI.
46 Grid
.SetColumn(chainImage
, 1)
47 Grid
.SetRow(chainImage
, 3)
48 croppedGrid
.Children
.Add(chainImage
)
51 End Class
'CroppedImageExample
52 End Namespace
'ImageElementExample