This project has moved and is read-only. For the latest updates, please go here.

Printing from VM

May 6, 2011 at 4:14 PM


Following code would solve the issue of printing the Visual from ViewModel. 

        public RelayCommand<Visual> PrintCommand
                return new RelayCommand
<Visual>( v =>
                    PrintDialog printDlg = new PrintDialog();
                    printDlg.PrintVisual( v, "Sample Printing." );
                } );

Have the following doubts,

1. Can I keep the Visual in VM?

2. I am planning to make the common Print view that has the header,footer and body UI element and all properties are bound with VM.

How can I call common Print view from any VM? Hope we should not have the reference of View in the VM. How could we archieve this?

Need the architectural guidance on this. Please advise.