I use a RadCartesianChart3D for displaying a 3D graph. For copying this graph to Clipboard, I render the view model again and copy it to the Clipboard. But that copy does not contain the axis labels.
I use the following code to copy the view model to Clipboard:
var data = new DataObject();
var bitmap = RenderToBitmap(this);
if (bitmap != null)
{
data.SetData(DataFormats.Bitmap, bitmap);
}
Clipboard.SetDataObject(data);
And RenderToBitmap is as follows:
public BitmapSource RenderToBitmap(object viewModel, double dpi = 300.0)
{
var element = new Border()
{
Child = new ContentControl()
{
Content = viewModel,
},
Background = new SolidColorBrush(Colors.White),
};
element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
element.Arrange(new Rect(element.DesiredSize));
element.InvalidateVisual();
element.UpdateLayout();
var target = new RenderTargetBitmap((int)(element.ActualWidth * dpi / 96.0), (int)(element.ActualHeight * dpi / 96.0), dpi, dpi, PixelFormats.Default);
target.Render(element);
return BitmapFrame.Create(target);
}
Why is the copy not containing the axis labels?