Adding background nodes via code

I currently have some nodes (background grid, print preview, etc) added to my diagram via XAML, but I would like to remove them from there and add them via code… How can I replicate the following in code?

<Diagram ...>
    < ... Temaplate ... />


Just construct the Node in code, as you would for any FrameworkElement.
Then add it to the Diagram.PartsModel.