Cannot Apply Custom Style for Printing

Hi,

I tried to change the print preview window icon and name using BasedOn property bound with SyncfusionChromelessWindowStyle as StaticResource defined in Style with the MaterialDark theme. I noticed a strange thing that applying custom style for printing has no effect after changing the icon and name with the above method.

PrintSettings.AllowPrintByDrawing and PrintSettings.AllowPrintStyles properties have been set to false. The following styles are defined under application resources to ensure the text is black since the text is by default white in MaterialDark.

<Style TargetType="syncfusion:PrintGridCell">
        <Setter Property="Foreground" Value="Black"/>            
    </Style>

    <Style TargetType="syncfusion:PrintHeaderCell">
        <Setter Property="Foreground" Value="Black"/>            
    </Style>

I use Syncfusion WPF UI V19.1.0.55 (NuGet) for .NET Core. Could you confirm this issue?

Regards,
Arvin

1 Reply 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team April 13, 2021 12:19 PM UTC

Hi Arvin,  
 
Thanks for the update.   
 
You can change the foreground of the PrintHeaderCell and PrintGridCell by creating CustomPrintManager as shown in the following code example.   
 
Code example :   
 
dataGrid.PrintSettings.PrintManagerBase = new CustomPrintManager(this.dataGrid);  
this.dataGrid.PrintSettings.PrintPreviewWindowStyle = App.Current.Resources["PrintWindowStyle"as Style;  
this.dataGrid.PrintSettings.AllowPrintByDrawing = false;  
this.dataGrid.PrintSettings.AllowPrintStyles = false;  
this.dataGrid.ShowPrintPreview();  
  
 public class CustomPrintManager : GridPrintManager  
 {  
     public CustomPrintManager(SfDataGrid grid)  
         : base(grid)  
     {  
     }  
  
     protected override object GetColumnElement(object record, string mappingName)  
     {  
         var columnElement = base.GetColumnElement(record, mappingName) as TextBlock; if (columnElement != null)  
         {  
             columnElement.Foreground = new SolidColorBrush(Colors.Blue);   
         }  
  
         return columnElement;  
     }  
  
     protected override UIElement GetColumnHeaderElement(string mappingName)  
     {  
         var columnElement = base.GetColumnHeaderElement(mappingName) as TextBlock; if (columnElement != null)  
         {  
             columnElement.Foreground = new SolidColorBrush(Colors.Blue);  
         }  
  
         return columnElement;  
     }  
 }  


 
 
Please lets us know if you require further assistance from us.   
 
Regards,  
Mohanram A.  


Marked as answer
Loader.
Up arrow icon