|
| ||||||||||
| Tags: microsoft, print, silverlight 4, windows vista, windows xp |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
: I don't know much about it, but I know the basic things. The HasMorePages property remember that indicates if our document is to print more pages, if HasMorePages is true then the event will fire again PrintPage until HasMorePages is false. I think I am right in this logic. Please help me in solving the problem.![]() |
|
#2
| |||
| |||
| Re: Not able to print multiple pages in Silverlight 4
We see that we have a ListBox which contains a list of music albums. In addition we are changing the DataTemplate to show a better way each of these elements. The following snippet shows the XAML of the application: Code: <UserControl x: Class = "Demo.SL4.ImpresionMultiple.MainPage"
xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns: local = "clr-namespace: Demo.SL4.ImpresionMultiple"
mc: ignore = "d"
d: DesignHeight = "300" d: DesignWidth = "500">
<UserControl.Resources>
<Local: Albums x: Key = "albums" />
<DataTemplate x: Key = "VistaDataTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width = "100" />
<ColumnDefinition />
</ Grid.ColumnDefinitions>
<Border BorderBrush = "Black" Padding = "3" BorderThickness = "2" CornerRadius = "10">
<Image Source = "(Binding picture)
Width = "100" />
</ Border>
<StackPanel Grid.Column = "1">
<TextBlock Text = "(Binding Title)"
FontSize = "20" />
<TextBlock Text = "(Binding Banda)" />
</ StackPanel>
</ Grid>
</ DataTemplate>
</ UserControl.Resources>
<Grid x: Name = "LayoutRoot" Background = "White" DataContext = "(StaticResource albums)">
<Grid.ColumnDefinitions>
<ColumnDefinition Width = "Auto" />
<ColumnDefinition Width = "*" />
</ Grid.ColumnDefinitions>
<ListBox Grid.Column = "1"
HorizontalAlignment = "Left"
Margin = "5"
Name = "listBox1"
VerticalAlignment = "Top"
Width = "450"
Height = "450"
ItemsSource = "(Binding)"
ItemTemplate = "(StaticResource VistaDataTemplate)" />
<StackPanel Height = "228"
HorizontalAlignment = "Left"
Name = "stackPanel1"
VerticalAlignment = "Top"
Margin = "5">
<Button Height = "50"
Name = "button1"
Width = "120">
<Button.Content>
<StackPanel>
<TextBlock HorizontalAlignment = "Center"> Print </ TextBlock>
<TextBlock HorizontalAlignment = "Center"> ListBox </ TextBlock>
</ StackPanel>
</ Button.Content>
</ Button>
<Button Height = "50"
Name = "button2"
Width = "120">
<Button.Content>
<StackPanel>
<TextBlock HorizontalAlignment = "Center"> Print </ TextBlock>
<TextBlock HorizontalAlignment = "Center"> Custom </ TextBlock>
</ StackPanel>
</ Button.Content>
</ Button>
</ StackPanel>
</ Grid>
</ UserControl> |
|
#3
| ||||
| ||||
| Re: Not able to print multiple pages in Silverlight 4 Printing Elements - PageVisual property object in the event arguments ultimately PrintPage indicates what the content to print and this content of the XAML tree or not. That is, if we set the ListBox as PageVisual ... Code: pd. PrintPage + = (s, a) => ( // Set the ListBox as PageVisual to.PageVisual = listBox1; ); |
|
#4
| |||
| |||
| Re: Not able to print multiple pages in Silverlight 4
We can achieve a higher degree of customization to dynamically create XAML content we want to print. In the case of this example dynamically generate a Canvas that contains a header, and a ItemsControl to display each and every one of the elements to print. Besides the above, we will ensure that enables printing multiple pages to print the records on each page correctly. |
|
#5
| |||
| |||
| Re: Not able to print multiple pages in Silverlight 4 Canvas - You create a Canvas that has the same size of the print area available, depending on the printer selected: Code: pd. PrintPage + = (s, a) => ( canvas = new Canvas () (Width = a.PrintableArea.Width, Height = a.PrintableArea.Height); ... Item List - This is the most important part of this scenario. We need to stand the fact that there will be more than one page when printing. In the example in this article we have an object called Rocket (List <Album>) which has a total of 42 albums. |
|
#6
| |||
| |||
| Re: Not able to print multiple pages in Silverlight 4
For custom printing call PrintDataTemplate create another DataTemplate which will display differently the same elements of the screen. For example, we will remove the image from each album and deploy the elements within a grid with four columns. The columns will show Title, Banda, Inventory and Release Date. The following excerpt shows the DataTemplate XAML for printing: Code: <ColumnDefinition Width = "120" /> <ColumnDefinition Width = "100" /> <ColumnDefinition Width = "100" /> </ Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height = "40" /> </ Grid.RowDefinitions> <TextBlock Text = "(Binding Title)" FontWeight = "Bold" Grid.Column = "0" /> <TextBlock Text = "(Binding) Banda" Grid.Column = "1" /> <TextBlock Text = "(Binding) Inventory" Grid.Column = "2" /> <TextBlock Text = "(Binding ReleaseDate) Grid.Column = "3" /> </ Grid> </ DataTemplate> |
|
#7
| |||
| |||
| Re: Not able to print multiple pages in Silverlight 4
Finally, in the event PrintPage invoke the methods of creating the header and the creation of items per page: Code: ...
CreateHeader ("List of albums");
CreateLilst (currentPage)
to.PageVisual = canvas;
to.HasMorePages =! (currentPage == totalPage)
... |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Not able to print multiple pages in Silverlight 4" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pages cut off when using Google Cloud Print to print from HP PSC1315xi printer | Shoana | Technology & Internet | 3 | 27-02-2012 09:21 AM |
| Silverlight is installed but not running on web pages | Bohdan | Technology & Internet | 5 | 19-04-2011 10:27 PM |
| Print large photo on multiple pages? | OctAvio2011 | Windows Software | 5 | 29-09-2010 03:45 AM |
| How can I print a picture on multiple pages to make it bigger? | NIcaBoy | MS Office Support | 1 | 13-05-2009 10:41 PM |
| Cannot print from web pages | RonaldA | Technology & Internet | 3 | 09-03-2009 06:43 PM |