I am working in a Silverlight 4 application. I have a datagrid that I would like to print. I am trying to use davidpoll printing functionality
Currently, I am printing just the datagrid header, but no items are being printed
<SLaB:CollectionPrinter x:Name="printer" ItemsSource="{Binding CurrentSearchView}" >
<SLaB:CollectionPrinter.BodyTemplate>
<DataTemplate>
<sdk:DataGrid x:Name="dgResults" VerticalAlignment="Stretch" SelectionMode="Single" HorizontalAlignment="Stretch" AutoGenerateColumns="False" ItemsSource="{Binding CurrentSearchView}" IsReadOnly="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" Margin="10" FontSize="12" FontFamily="Segoe UI" >
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding PeopleId}" Header="People ID" Width="150"/>
<sdk:DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="*" MinWidth="80"/>
<sdk:DataGridTemplateColumn Header="FQ" Width="80">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel x:Name="spFq" Background="{Binding FqBackground}" Margin="2">
<Image Source="{Binding FqImagePath}" Margin="4" Height="24" Width="24"/>
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="LQ" Width="80" CellStyle="{StaticResource BrowseQualityCellStyle}">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel x:Name="spLq" Orientation="Horizontal" Background="{Binding LqBackground}" Margin="2" >
<myControls:PlayButtonControl x:Name="playControl" Margin="4" Height="24" Width="24" />
<Image Source="{Binding LqImagePath}" Margin="4" Height="16" Width="16"/>
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTextColumn Binding="{Binding Format}" Header="Format" Width="Auto"/>
<sdk:DataGridTextColumn Binding="{Binding Duration}" Header="Duration" Width="Auto"/>
<sdk:DataGridTextColumn Binding="{Binding Attachment}" Header="Attachment" Width="Auto"/>
<sdk:DataGridTextColumn Binding="{Binding Restore}" Header="Restore" Width="Auto"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</DataTemplate>
</SLaB:CollectionPrinter.BodyTemplate>
</SLaB:CollectionPrinter>
And here is the button command
<Button Command="{Binding PrintCommand, ElementName=printer}">Print</Button>
Note that both, the collectionprinter and datagrid are referencing the same property CurrentSearchView, which is a PagedCollectionView. I think that my problem lies there, maybe I am not able to used this kind of collection (i also try with an observable collection and found the same results), or my bindings are wrong (having both controls referencing the same property, doesn’t seem right)
Any help will be greatly appreciated.
Thanks
I have found the problem. I needed to set the binding of the datagrid to “CurrentItems”