private void btn_Click(object sender, RoutedEventArgs e)
{
// Print Header Template
treeGrid.InternalGrid.PrintHeaderHeight = 50;
treeGrid.InternalGrid.PrintHeaderTemplate = Application.Current.FindResource("PrintHeaderTemplate") as DataTemplate;
// Print Footer Template
treeGrid.InternalGrid.PrintFooterHeight = 50;
treeGrid.InternalGrid.PrintFooterTemplate = Application.Current.FindResource("PrintFooterTemplate") as DataTemplate;
treeGrid.ShowPrintDialog();
} |
// Header Template
<DataTemplate x:Key="PrintHeaderTemplate">
<Grid>
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="20"
Text="Employee Details" />
</Grid>
</DataTemplate>
// Footer Template
<DataTemplate x:Key="PrintFooterTemplate">
<Grid>
<TextBlock HorizontalAlignment="Center"
FontSize="20"
Text="{Binding Source={x:Static sys:DateTime.Today},
StringFormat='{}{0:dddd, MMMM dd, yyyy}'}" >
</TextBlock>
</Grid>
</DataTemplate> |