In a previous question I was trying to print from my TreeView, now i go to the parent view and I have hare an UserControl how contain an TreeView to display my search result on my WPFview, i tryed to print it and i surround with FlowDocumentScrollViewer as the code below:
view.xaml
<FlowDocumentScrollViewer x:Name="flow" Margin="10" BorderThickness="0">
<FlowDocument>
<Section>
<BlockUIContainer>
<my:SearchTreeView Content="{Binding Stvm}"/>
</BlockUIContainer>
</Section>
</FlowDocument>
view.xaml.cs
Printing.PrintDoc( flow.Document, txtSearch.Text + " - Result");
static printing.cs
public static void PrintDoc(System.Windows.Documents.FlowDocument fd, string description)
{
double h, w, cw;
h = fd.PageHeight ;
w = fd.PageWidth ;
cw = fd.ColumnWidth;
PrintDialog pd = new PrintDialog();
//pd.PageRangeSelection = PageRangeSelection.AllPages;
//pd.UserPageRangeEnabled = true;
if (pd.ShowDialog() != true || fd == null) return;
fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWidth;
fd.PagePadding = new Thickness(50);
fd.ColumnGap = 0;
fd.ColumnWidth = pd.PrintableAreaWidth;
System.Windows.Documents.IDocumentPaginatorSource dps = fd;
// int c = dps.DocumentPaginator.PageCount;//0
pd.PrintDocument(dps.DocumentPaginator, description);
fd.PageHeight = h;
fd.PageWidth = w;
fd.PagePadding = new Thickness(0);
fd.ColumnWidth = cw;
}
i tryed almost all the exmple in the Similar Questions but the best i got is just the first page of result like this.. ;(
I'm Using WPF MVVM pattern. Is this is the right control to do it?Or shall I go for any other WPF controls.?