dgOutStorage.PrintSettings = new PrintSettings();
dgOutStorage.PrintSettings.PrintManagerBase = new CustomPrintManager(this.dgOutStorage);
dgOutStorage.PrintSettings.AllowPrintStyles = false;
dgOutStorage.PrintSettings.PrintScaleOption = PrintScaleOptions.FitAllColumnsonOnePage;
dgOutStorage.PrintSettings.PrintPageOrientation = PrintOrientation.Portrait;
DataTemplate cardLayout = new DataTemplate();
FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(TextBlock));
cardHolder.SetValue(TextBlock.TextProperty, title);
cardHolder.SetValue(TextBlock.FontSizeProperty, 20.0);
cardHolder.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
cardLayout.VisualTree = cardHolder;
dgOutStorage.PrintSettings.PrintPageHeaderTemplate = cardLayout;
dgOutStorage.PrintSettings.PrintPageHeaderHeight = 30;
dgOutStorage.PrintSettings.PrintPageMargin = new Thickness(2.5, 2.5, 2.5, 2.5);
dgOutStorage.Print();
1.Print result like 1.oxps,stackheader not print.
2.PrintPageMargin not working.