WPF Style Trigger

styles, triggers, wpf

Solution

A nice trick to isolate an element from its parent layout wise is to place the element in a Canvas

In the markup below there are two copies of your element The first is hidden and establishes the size of your control The second is visible but wrapped in a Canvas so its layout size does not affect the parent.

<Parent>
  <Grid>
    <Element Visibility="Hidden"/>
    <Canvas>
      <Element />
    </Canvas>
  <Grid>
</Parent>

Problem

I change the FontSize of Text in a Style trigger, this causes the Control containing the text to resize as well. How can I change the Fontsize without affecting the parent's size?

Original source