xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PrintVisual" Height="259" Width="282">
//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes
Namespace Printing
Public Partial Class PrintVisual
Inherits System.Windows.Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub cmdPrint_Click(sender As Object, e As RoutedEventArgs)
Dim printDialog As New PrintDialog()
If printDialog.ShowDialog() = True Then
Dim zoom As Double = 30
canvas.Background = Brushes.LightSteelBlue
canvas.LayoutTransform = New ScaleTransform(zoom / 100, zoom / 100)
Dim pageSize As New Size(printDialog.PrintableAreaWidth - 20, printDialog.PrintableAreaHeight - 20)
canvas.Measure(pageSize)
canvas.Arrange(New Rect(10, 10, pageSize.Width, pageSize.Height))
printDialog.PrintVisual(canvas, "A Scaled Drawing")
canvas.Background = Nothing
canvas.LayoutTransform = Nothing
End If
End Sub
End Class
End Namespace