0

So the following does the first part:

<Expander>
<Expander.Style>
    <Style TargetType="Expander">
        <Setter Property="IsExpanded" Value="False" />
        <Setter Property="Header" Value="See More" />

        <Style.Triggers>
            <DataTrigger Binding="{Binding IsExpanded,RelativeSource={RelativeSource Self}}" Value="True">
                <Setter Property="Header" Value="See Less" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Expander.Style>
</Expander>

But what if I want the header size to be 16pt too? Can't think of the correct syntax.

dan1st
  • 12,568
  • 8
  • 34
  • 67
apokryphos
  • 21
  • 5

1 Answers1

1

There is no direct way of modifying header. You need to create custom template to change property of header only.

But there is a easy workaround which I used. You can change the font size in the trigger for the full expander like <Setter Property="FontSize" Value="16"/>. And have the fontsize of children explicitly set to 12(or the default value) or also can bind the children fontsize to the expander's parent fontsize. This will make expander children to remain as 12 or to expander's parent fontsize and trigger will not have any affect on them, so only header will be changing.

Rohit Agrawal
  • 335
  • 1
  • 2
  • 9
  • Yeah that's really not ideal though, I have a good 20 or so items underneath; setting their site explicitly is really messy :-/ – apokryphos Jul 29 '12 at 04:57
  • You will be putting in some group like stackpanel or grid. Then in its resource you can put the style for that type of control. Incase you have many varities of controls, then you can use object as the type. – Rohit Agrawal Jul 29 '12 at 05:03