Hello,
I would like to print the xamNetworkNode. I do not want to use PrintVisual. Is there anyway i could create a flow document and print that?
Thanks
Rohit
Hi Rohit,
Your code looks fine but you are missing some things. You are instantiating a XamNetworkNode control here and setting the ItemsSource but you also need to provide a NetworkNodeNodeLayout to the XamNetworkNode.GlobalNodeLayouts collection. This lets the control know how to read the data in the ItemsSource.
Another issue is the XamNetworkNode needs to have been rendered at least once so they nodes are created. A simple approach for this would be to have XamNetworkNode control already part of your application but hidden if you don't want to see it. You can then provide this control to the FlowDocument. Make sure you remove the network node control from it's container or an error will be thrown.
I've attached a sample application that demonstrates all of this. Let me know if you have any questions on it.
I tried to create the flow document as you suggested:
FlowDocument
fDoc = new FlowDocument();
BlockUIContainer bContainer = new BlockUIContainer();
XamNetworkNode Temp = new XamNetworkNode();
Temp.NodeDistance = InNodeDistance;
Temp.SelectionType =
NetworkNodeSelectionType.Single;
Temp.ItemsSource = NetworkNodes;
bContainer.Child = Temp;
fDoc.Blocks.Add(bContainer);
For printing i used steps in the following link:
http://roecode.wordpress.com/2007/12/21/using-flowdocument-xaml-to-print-xps-documents/
It printed a blank page. Could you please tell me what am i doing wrong here?
I've looked into your requirements and I believe you should be able to use a FlowDocument where you can embed the XamNetworkNode control and then print the flow document with the PrintDialog.PrintDocument method. In order to embed the XamNetworkNode within a FlowDocument you will need to contain it within a BlockUIContainer.