I am a beginner in WPF (and C# in XAML in general) and currently trying to save a Grid filled with WindowsFormsHosts (modified as given here for compatibility with ScrollViewer) in turn containing charts from DataVisualization.Charting to an image.
I've tried both of the answers to this question - using the Grid as the 'content' for the first answer - with no avail (saves a black image of the correct dimensions)
The snippet below is my current layout. Any XY problem challenges - such as a way to render DataVisualization.Charting charts without using WindowsFormsHost - are welcome, as I am very much a greenhorn. However the ScrollViewers are needed due to the size of the full Grid, and the entire Grid (including the area that needs to be scrolled to) must be saved in its entirety.
<TabControl x:Name="tabcontrol" Margin="5,0">
<TabItem Header="1" Width="30" Visibility="Hidden" Name="tabitem0">
<ScrollViewer Margin="5" CanContentScroll="False" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Name="Scroll">
<Grid x:Name="ChartGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<wpfrichtextbox:ScrollViewerWindowsFormsHost x:Name="Chart1" Visibility="Visible" Grid.Row="0" Grid.Column="1" Margin="0"
HorizontalAlignment="Center" VerticalAlignment="Center"/> //A DataVisualization.Charting chart contained in each WindowsFormsHost, repeated throughout Grid
</Grid>
</ScrollViewer>
</TabItem>
</TabControl>