I have a control that I am converting to an image using the method here :
Force rendering of a WPF control in memory
Unfortunately I have a complex layout and it
In the end I had to use a trigger to set the height to zero instead of applying Collapsed
to the elements. Of course this means any margins must be converted to padding, with nested panels if needed.
In this instance I had a border control - so I had to remove the Visibility property and use this trigger instead.
<Border>
<Border.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding XXXXX, Converter={StaticResource booleanConverter}}" Value="true">
<Setter Property="Border.Height" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>