TextArea.Print("test", Telerik.Windows.Documents.UI.PrintMode.Native)
But it throws an exception.
If I set it to Visible before calling Print then it works....Can anybody help me?
6 Answers, 1 is accepted

Private
m_oTextBox
As
Telerik.Windows.Controls.RadRichTextBox
m_oTextBox =
New
Telerik.Windows.Controls.RadRichTextBox()
m_oTextBox.Width = 0
m_oTextBox.Height = 0
Me
.LayoutRoot.Children.Add(m_oTextBox)
Try
m_oTextBox.Document = TextArea.Document
m_oTextBox.ApplyTemplate()
m_oTextBox.UpdateEditorLayout()
m_oTextBox.ActiveEditorPresenter =
New
Telerik.Windows.Documents.UI.DocumentPrintPresenter(
New
Telerik.Windows.Documents.UI.PrintSettings())
AddHandler
CType
(m_oTextBox.ActiveEditorPresenter, Telerik.Windows.Documents.UI.DocumentPrintPresenter).PrintingCompleted,
AddressOf
MainPage_PrintingCompleted
m_oTextBox.Print("Test Document", Telerik.Windows.Documents.UI.PrintMode.Native)
Catch
ex
As
Exception
Me
.LayoutRoot.Children.Remove(m_oTextBox)
Throw
End
Try
Sub
MainPage_PrintingCompleted(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Me
.LayoutRoot.Children.Remove(m_oTextBox)
End
Sub
where TextArea.Document is another RadRichtextBox (use just for the example to populate m_oTextBox )
The problem is that PrintingCompleted doesn't work properly and even if I put a breakpoint in MainPage_PrintingCompleted
it will never be used. Runtime does't go into the function.
It's nice to see that you've reached so far on your own. However there is no need to set the ActiveEditorPresenter property to a new instance of DocumentPrintPresenter. This is done internally inside the Print method of the RadRichTextBox. In fact this is the reason why your event handler isn't called.
If you need to use the printing functionality the RadRichTextBox instance should be involved in the layout passes of the Silverlight application. That's why you should add the control to the visual tree and it should not be collapsed. If the Visibility of the the rich text box is set to Collapsed it is not measured/arranged by the Silverlight layout system. So the recommended approach if you want to use "hidden" RadRichTextBox for printing is to set the Opacity property to 0.
Alex
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

m_oTextBox.ActiveEditorPresenter =
New
Telerik.Windows.Documents.UI.DocumentPrintPresenter(
New
Telerik.Windows.Documents.UI.PrintSettings())
I have an exception
Unable to cast object of type 'Telerik.Windows.Documents.UI.DocumentPrintLayoutPresenter'
to type 'Telerik.Windows.Documents.UI.DocumentPrintPresenter'.
in
AddHandler
CType
(m_oTextBox.ActiveEditorPresenter, Telerik.Windows.Documents.UI.DocumentPrintPresenter).PrintingCompleted,
AddressOf
MainPage_PrintingCompleted
Don't understand what 's the problem???
The event is not fired, because RadRichTextBox creates a new DocumentPrintPresenter when you invoke the print method/command. Therefore, the PrintingCompleted event of the print presenter you create is never fired. We will review the API, so that it would be possible to detect when printing has been completed.
All the best,
Iva
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

As I understand that's not possible now to catch the PrintCompleted event until you fix API.That event is really important for me because I try to close a screen where I call the Print function and it throws an exception.It happens because SL still works with printing when I close a window(actually a UserControl).Therefore,I need to close a window in the PrintCompleted event handler but not after calling the Print function......And now I am stuck
We do agree that this event will be suitable for a broad range of scenarios and will make sure to add it to the API as soon as possible, in the upcoming Q3 at latest.
Kind regards,Iva
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!