This is a migrated thread and some comments may be shown as answers.

Add Print functionality for Radwindow from code behind

1 Answer 25 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 19 Feb 2013, 02:32 PM
Hi,

I am openning a radwindow on button click from code behind as below in silverlight 5 app:

 RadWindow newChldWindow = newRadWindow();
            newChldWindow.Closed += popUpCloseEvent;
            newChldWindow.Height = 650;
            newChldWindow.Width = 1000;
            newChldWindow.ResizeMode = ResizeMode.CanResize;
            newChldWindow.CanMove = true;

Would it be possible to add print functionality to this from code behind? 

PS. I can move this whole functionality to a control if necessary(which i tried and didn't succeed by using  this and this KB articles)


Thanks

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 22 Feb 2013, 09:59 AM
Hi Sam,

You could easily print the content of RadWindow like this:

Let's, for example, the root Grid element in the RadWindow is defined like this:

<Grid x:Name="LayoutMain">
    ...
    <Button Content="Print" Click="Button_Click"  />
   ... 
</Grid>

So in the Button_Click event handler add the following code snippet:

private void Button_Click(object sender, RoutedEventArgs e)
{
    var doc = new PrintDocument();
 
    doc.PrintPage += new EventHandler<PrintPageEventArgs>(doc_PrintPage);
    doc.Print("Window Page");
}
 
private void doc_PrintPage(object sender, PrintPageEventArgs e)
{
    e.PageVisual = LayoutMain;   
    e.HasMorePages = false;
}

Hope this helps.

All the best,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Window
Asked by
Sam
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or