Add Print functionality for Radwindow from code behind

2 posts, 0 answers
  1. Sam
    Sam avatar
    19 posts
    Member since:
    Nov 2011

    Posted 19 Feb 2013 Link to this post


    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)

  2. Yana
    Yana avatar
    4547 posts

    Posted 22 Feb 2013 Link to this post

    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"  />

    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,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
Back to Top