WPF Xaml control converted to an image has incorrect layout

后端 未结 1 1612
后悔当初
后悔当初 2021-01-25 21:25

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

相关标签:
1条回答
  • 2021-01-25 22:01

    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>
    
    0 讨论(0)
提交回复
热议问题