Changing Icon of PrintingService Dialog in SfDiagram

Is it possible to change the icon of the PrintingService Dialog in the SfDiagram?

12 Replies 1 reply marked as answer

PP Prakash Perumal Syncfusion Team March 23, 2021 09:40 AM UTC

Hi  Joost van Gils,


Greetings from Syncfusion. 


We can change the icon of the Print Preview dialog by updating PrintPreviewWindow’s Icon property as below:

<Application x:Class="SfDiagram_Sample.App"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:diagramControls="clr-namespace:Syncfusion.UI.Xaml.Diagram.Controls;assembly=Syncfusion.SfDiagram.WPF"

             StartupUri="MainWindow.xaml">

    <Application.Resources>

        <Style TargetType="diagramControls:PrintPreviewWindow">

            <Setter Property="Icon" Value="/SfDiagram Sample;component/App.ico"/>

        </Style>

    </Application.Resources>

</Application>

 

Regards,

Prakash P



JV Joost van Gils March 23, 2021 11:11 AM UTC

Hello Prakash,

Thank you for your reply. Unfortunately the provided code doesn't seem to work when calling the print preview of the SfDiagram by use of the 'PrintingService'.
Any ideas how to make this work?
Regards,

Joost



KR Karkuvel Rajan Shanmugavel Syncfusion Team March 24, 2021 04:39 AM UTC

Hi Joost, 
 
We suspect that you have used the provided code in the resources of main window. This code won’t work in main window because we have open an new window for Printing. So, we have to use the code in Application resources. We have provided the sample for your requirement. Please find the sample below. 
 
 
Regards, 
Karkuvel Rajan S 



JV Joost van Gils March 24, 2021 06:28 AM UTC

Hello Prakash,

Thanks again for the example. I've examined it and concluded I was using the code in the right way.
Now I think I've found a bug.
This is the case: the code is working in the proper way when I don't apply any Theme to the entire application.
In my case I'm using the Office2019Black theme. The theme is set in this way at right after the InitializeComponent() of the main window:

Theme theme = new Theme("Office2019Black");
SfSkinManager.ApplyStylesOnApplication = true;
SfSkinManager.SetTheme(this, theme);

and after this is set and I call this:

MainDiagram.PrintingService.ShowDialog = true;
MainDiagram.PrintingService.Print();

the SyncFusion Icon will be shown on the PrintPreview Dialog instead of the Icon that is set in the App.xml.
Regards,

Joost


JV Joost van Gils March 24, 2021 06:32 AM UTC

Hello Prakash,

Thanks again for the example. I've examined it and concluded I was using the code in the right way.
Now I think I've found a bug.
This is the case: the code is working in the proper way when I don't apply any Theme to the entire application.
In my case I'm using the Office2019Black theme. The theme is set in this way at right after the InitializeComponent() of the main window:

Theme theme = new Theme("Office2019Black");
SfSkinManager.ApplyStylesOnApplication = true;
SfSkinManager.SetTheme(this, theme);

and after this is set and I call this:

MainDiagram.PrintingService.ShowDialog = true;
MainDiagram.PrintingService.Print();

the SyncFusion Icon will be shown on the PrintPreview Dialog instead of the Icon that is set in the App.xml.
Regards,

Joost


KR Karkuvel Rajan Shanmugavel Syncfusion Team March 24, 2021 01:25 PM UTC

Hi Joost, 

Thanks for the update. We have found that you have used our themes and tried to modified the PrintPreview window icon. For this we have to add only the resources not to apply theme for the whole window. So, please remove the themes code from your sample. For your requirement we have provided a simple sample and code example. Please find the sample and code example below. 

Code Example:  


    <Application.Resources> 
        <ResourceDictionary> 
            <ResourceDictionary.MergedDictionaries> 
                <ResourceDictionary Source="/Syncfusion.Themes.Office2019Colorful.WPF;component/SfDiagram/SfDiagram.xaml"/> 
                <ResourceDictionary Source="/Syncfusion.Themes.Office2019Colorful.WPF;component/PrintPreview/PrintPreview.xaml"/> 
            </ResourceDictionary.MergedDictionaries> 
 
            <Style TargetType="diagramControls:PrintPreviewWindow" BasedOn="{StaticResource SyncfusionPrintPreviewWindowStyle}"> 
                <Setter Property="Icon" Value="/Simple SfDiagram WPF;component/Asset/Symbol.png"/> 
            </Style> 
             
        </ResourceDictionary> 
    </Application.Resources> 




Regards, 
Karkuvel Rajan S 



AS Arvin Staff April 6, 2021 07:40 AM UTC

Hi,

What about modifying the icon of SfDataGrid's print preview window icon? Could you tell me what should be placed instead of diagramControls namespace?

Regards,
Arvin


MA Mohanram Anbukkarasu Syncfusion Team April 7, 2021 12:31 PM UTC

Hi Arvin Staff, 

Thanks for the update.  

You can change the print preview window icon of the SfDataGrid as shown in the following code example.  

Code example :  

<Application.Resources> 
    <Style TargetType="syncfusion:ChromelessWindow" x:Key="PrintWindowStyle"> 
        <Setter Property="Icon" Value="..\..\print.png"/> 
        <Setter Property="Title" Value="Print Preview"/> 
    </Style> 
</Application.Resources> 
 
 
this.dataGrid.PrintSettings.PrintPreviewWindowStyle = App.Current.Resources["PrintWindowStyle"] as Style; 


Please let us know if you require further assistance from us.  

Regards, 
Mohanram A. 



AS Arvin Staff April 7, 2021 11:48 PM UTC

Hi,

Thanks for your reply! What if I want to apply the MaterialLight theme? Could you provide more information about it?

Regards,
Arvin


VS Vijayarasan Sivanandham Syncfusion Team April 8, 2021 10:37 AM UTC

Hi Arvin Staff,

Thanks for the update.

Your requirement can be achieved by Adding the ResourceDictionary of MaterialLight Theme in SfDataGrid. Basedon property binded with SyncfusionChromelessWindowStyle as StaticResource defined in Style. Please refer the below code snippet, 
<Application.Resources> 
        <ResourceDictionary> 
            <ResourceDictionary.MergedDictionaries> 
                <ResourceDictionary Source="/Syncfusion.Themes.MaterialLight.WPF;component/GridPrintPreviewControl/GridPrintPreviewControl.xaml" />                
            </ResourceDictionary.MergedDictionaries> 
            <Style TargetType="syncfusion:ChromelessWindow" x:Key="PrintWindowStyle" BasedOn="{StaticResource SyncfusionChromelessWindowStyle}"> 
            <Setter Property="Icon" Value="..\..\print.png"/> 
            <Setter Property="Title" Value="Print Preview"/> 
        </Style> 
        </ResourceDictionary> 
    </Application.Resources> 

Please let us know, if you require further assistance on this.

Regards,
Vijayarasan S 



AS Arvin Staff April 9, 2021 03:54 AM UTC

Hi,

I tried to do this with the MaterialDark theme (just changed MaterialLight to MaterialDark). I noticed a strange thing that applying custom style for printing has no effect.

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


MA Mohanram Anbukkarasu Syncfusion Team April 12, 2021 01:50 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