tags:

views:

34

answers:

1

Hi,

I am trying to create an image of a user control. The usercontrol is created dynamically.

MyViewsUserControl myViewsCanvas = new MyViewsUserControl(MyViewsViewModel, item.Id);

The usercontrols have a grid and in some cases a chart.I am creating the image using 'RenderTargetBitmap' class. But for some reason the image for grid and chart are not being created. Can anyone tell me what the problem is? Is this because the user control is not loaded yet?

Note:I am creating the image before loading the user control.

here is the code for this:

 MyViews.MyViewsUserControl myViewsCanvas = new MyViews.MyViewsUserControl(AllFoundationMyViewsViewModel, item.Id);
 myViewsCanvas.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
 myViewsCanvas.Arrange(new Rect(new Point(), myViewsCanvas.DesiredSize));
 myViewsCanvas.UpdateLayout();
 screenInfo _screenInfo = new screenInfo(item.Id, item.MonarchMenuItem, "MyViews");
 UpdateControls(_DashBoardUserControl, i, myViewsCanvas, _screenInfo, item.MonarchMenuItem.DisplayName);

I am creting the image in updateControls() method.

A: 

Don't forget to call the user control's Measure, Arrange and UpdateLayout before trying to render the control into the bitmap

Nir
Yeah i am doing that. But still facing the problem.