BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
<Application.Resources>
<DataTemplate x:Key="PageHeaderTempalte">
<Grid Background="Gray">
<TextBlock Text="{Binding ReportTitle}"
FontSize="18"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"/>
</Grid>
</DataTemplate>
</Application.Resources>
PrintManagerBase is the DataContext
for PrintPageControl, where the header and footer templates are loaded. Where you can override print manager and pass DataContext to Header and Footer templates. You can find the sample and code snippet details below,
public class GridPrintManagerExt: GridPrintManager
{
public GridPrintManagerExt(SfDataGrid datagrid) : base(datagrid)
{
}
SfDataGrid _dataGrid;
public SfDataGrid DataGrid
{
get { return dataGrid; }
set { _dataGrid = value; }
}
}
dataGrid.PrintSettings.PrintManagerBase = new GridPrintManagerExt(dataGrid);
dataGrid.PrintSettings.PrintPageHeaderTemplate = App.Current.Resources["PageHeaderTempalte"] as DataTemplate;
dataGrid.PrintSettings.PrintPageHeaderHeight = 30;
dataGrid.ShowPrintPreview(); |
<Application.Resources>
<DataTemplate x:Key="PageHeaderTempalte">
<Grid Background="Gray">
<TextBlock
FontSize="18"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center">
<TextBlock.Text>
<Binding Path="DataContext.DataGrid.DataContext.ReportTitle"
RelativeSource="{RelativeSource Mode=FindAncestor,
AncestorType={x:Type syncfusion:PrintPageControl}}"
StringFormat="-- {0} --" />
</TextBlock.Text>
</TextBlock>
</Grid>
</DataTemplate>
</Application.Resources> |