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 seems that a control being 'Collapsed' isn't actually being hidden properly in the output image.
Tried:
- Call
UpdateLayout
multiple times - Change size of control by 1 pixel
- Using a ViewBox
It seems to affect DockPanel if something is aligned to the bottom and hidden with a converter.
<DockPanel LastChildFill=True>
<Something Dock.Panel="Top" />
<Something Dock.Panel="Bottom" Binding="{Binding XXXXX, Converter={StaticResource booleanConverter}}"/>
<Something Dock.Panel="Bottom" Binding="{Binding YYYYY, Converter={StaticResource booleanConverter}}"/>
<Something />
</DockPanel>
Everything displays just fine in the Xaml editor, or if it is used at runtime in a real visible control.
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.