views:

556

answers:

1

Hi,
I am trying to change the expander backgraund color, It seems so easy but I can't do that.

<Expander Name="expOneDay">
<Expander.Header>
<TextBlock Foreground="CadetBlue" Text="Some Text" HorizontalAlignment="Stretch" />
</Expander.Header>
...
</Expander>

why HorizontalAlignment="Stretch" doesn't help? I am trying to bind the with of header to the with of expander but the resoult is not nice looking
Thanks a lot

+2  A: 

here you go, this should do the trick....

<Expander Name="expOneDay" 
          HorizontalAlignment="Stretch"
          HorizontalContentAlignment="Stretch" Width="Auto">
     <Expander.Header >
          <Border Background="Bisque">
               <TextBlock Foreground="White" Text="Steve" 
                          Width="{Binding ElementName=expOneDay, Path=ActualWidth}"
                          HorizontalAlignment="Stretch" />
          </Border>
     </Expander.Header>
</Expander>
Muad'Dib
Good answer, but i tried that allready, it doesn't help, it seems that the header becomes bigger than expander
ArsenMkrt
funny, worked fine for me--should be exactly the same width. you could make a converter that takes the width and subtracts some amount from it, returning the result.
Muad'Dib