The code works great!
However, I have a problem when printing the map with a graphic layer. In my application, I have a identify tool. When user click on the property, it gets highlighted and info is displayed. When creating the print map, the map has the highlighted graphic too which is what i wanted. Once the print map window is dismissed either from closing or printing, the graphic on the main map disappears. And, if user use the identify tool again, the app stops at the line where I add the graphic to the graphicsLayer on the main map. See attached document.
The app is ok if there is no graphics added to the print map. Looks like when the childwindow for print map got dismissed, it somehow destroy the graphiclayer in the main map or something.