Ricardo Magalhães
Ricardo Magalhães

Reputation: 227

wpf expander style that has a dynamic icon

I'm trying to use the blend to create a style to a expander control. I need to define a icon in the style that should by dynamic. In practical i have one only style that will be attached to multiple expanders and each one should be capable to define his icon (source property). Can someone help me with this issue! Thanks in advance for the help!

Upvotes: 1

Views: 592

Answers (1)

Ricardo Magalhães
Ricardo Magalhães

Reputation: 227

I found a solution. Instead of define the Header as a attribute:

<Expander Header="Expander Title" >
...
</Expander>

we must define the Header as a element:

<Expander>
<Expander.Header>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="20" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="50" />
      <ColumnDefinition Width="50" />
    </Grid.ColumnDefinitions>

    <Image Grid.Row="0" Grid.Column="0" Width="15" Source="Resources/Images/image.png"/>
    <TextBlock Grid.Row="0" Grid.Column="1"><Run Language="pt-pt" Text="ExpanderTitle"/></TextBlock>
  </Grid>
 </Expander.Header>

...

Upvotes: 1

Related Questions