I think the present implementation of PivotItem is somewhat inconsistent not to say flawed. If the property Header is set before or after it has been rendered completely the size of the header is set appropriately, however, setting the Header back to null or string.empty does not cause the header to shrink again. Is there an elegant way of hiding and showing a PivotItem header when the Header is set via DataBinding or can a PivotItem be forced to revalidate it’s boundaries?
As of now I’m trying “solve” my problem with some rather crude code which includes Events and the complete recreation of the Pivot programmatically and then attach all the PivotItems again. Maybe an OK solution for just page, but certainly somewhat iffy when this needs to be done 10+ times.
[This question has been asked before in a somewhat similiar context, but was never really solved.]
What I found is that changing the Visiblity or reducing the header height of a PivotItem simply doesn’t work (yet?) on an already rendered item. It’s simply broken, but it is possible to circumnavigate those shortcomings by moving the first child element of a PivotItem through changing its top margin to a negative value. Admittedly not elegant, but working. Here is some code:
Code behind