The most natural option would be to define the content of the stack panel in the report itself:
<r:CustomReportItem Location="0,50" Size="50%,200">
<r:CustomReportItem.Template>
<DataTemplate>
<StackPanel>
<local:DataControl />
</StackPanel>
</DataTemplate>
</r:CustomReportItem.Template>
</r:CustomReportItem>
Then the DataControl will be loaded automatically when the report is rendered or printed.
However, if you want to modify the contents of the stack panel dynamically, you have two options. Both of them require to handle the Report.Prerender event. The easier of the two approaches simply uses the custom report item as a placeholder. Then, in the Prerender event handler this placeholder is replaced with a stack panel and the content of the stack panel can be modified dynamically. Define an empty 'placeholder' item:
<r:CustomReportItem Location="0,50" Size="50%,200" x:Name="custReportItem" />
Then replace this item before rendering within the Prerender event handler:
if (e.Item.Name == "custReportItem")
{
StackPanel panel = new StackPanel();
panel.Children.Add(new DataControl());
e.RootVisual = panel;
}
The second approach is to dig up the stack panel from the RootVisual passed as argument to the Prerender event. The RootVisual of a CustomReportItem is a ContentControl. However, at the time the Prerender event is called the template of this control is not yet loaded so the stack panel is not created. Therefre you have to additionally listen to the ContentControl's Loaded event before you are able to find the stack panel in the visual tree.
Let me know if this helps.
Regards,
Meppy