Hi,
I have this scenario: I want to create from code behind some RadDiagrams, then export every diagram to a single PNG image without open and display the raddiagram.
Below there is my two solutions of code which don't work. IN particular, the stream is always empty.
1)
var myGraphSource = new GraphSource(); //this contains a list of shapes and connections
var diagram = new RadDiagram();
diagram.GraphSource = myGraphSource ;
diagram.SelectAll();
using (var stream = new MemoryStream()) {
diagram.ExportToImage(stream, margin: new Thickness(0,0,0,0), backgroundBrush: new SolidColorBrush(Colors.White));
image = stream.ToArray();
}
2)
var diagramViewModel = new DiagramViewModel(myGraphSource);
var diagramView = new DiagramView();
diagramView.DataContext = diagramViewModel;
using (var stream = new MemoryStream()) {
diagramView.diagram.ExportToImage(stream, margin: new Thickness(0,0,0,0), backgroundBrush: new SolidColorBrush(Colors.White));
image = stream.ToArray();
}
In both cases the code doesn't work and in the last scenario, I' ve bounded the GraphSource in the xaml. Is there a way to get my issue????
Thanks
Ciro
I have this scenario: I want to create from code behind some RadDiagrams, then export every diagram to a single PNG image without open and display the raddiagram.
Below there is my two solutions of code which don't work. IN particular, the stream is always empty.
1)
var myGraphSource = new GraphSource(); //this contains a list of shapes and connections
var diagram = new RadDiagram();
diagram.GraphSource = myGraphSource ;
diagram.SelectAll();
using (var stream = new MemoryStream()) {
diagram.ExportToImage(stream, margin: new Thickness(0,0,0,0), backgroundBrush: new SolidColorBrush(Colors.White));
image = stream.ToArray();
}
2)
var diagramViewModel = new DiagramViewModel(myGraphSource);
var diagramView = new DiagramView();
diagramView.DataContext = diagramViewModel;
using (var stream = new MemoryStream()) {
diagramView.diagram.ExportToImage(stream, margin: new Thickness(0,0,0,0), backgroundBrush: new SolidColorBrush(Colors.White));
image = stream.ToArray();
}
In both cases the code doesn't work and in the last scenario, I' ve bounded the GraphSource in the xaml. Is there a way to get my issue????
Thanks
Ciro