Expander et style du Header
Salut,
J'essaie, sans succès, d'appliquer un background au header d'un Expander.
- Si je mets le background directement sur l'expander, ça l'applique à l'expander entier
- Si je mets comme Header un TextBox avec le background voulu, il n'occupe pas tout l'espace du Header
Voilà le code et le screenshot qui illustrent les 2 cas :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <Window x:Class="WpfCS.TestExpander2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestExpander2" Height="300" Width="300">
<Window.Resources>
<LinearGradientBrush x:Key="brushExpander" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="#FFF3F3F3"/>
<GradientStop Offset="0.5" Color="#FFEBEBEB"/>
<GradientStop Offset="0.5" Color="#FFDDDDDD"/>
<GradientStop Offset="1" Color="#FFCDCDCD"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Expander Grid.Row="0"
IsExpanded="True"
Header="Hello world"
Background="{StaticResource brushExpander}">
<Rectangle Height="100"/>
</Expander>
<Expander Grid.Row="1"
IsExpanded="True">
<Expander.Header>
<TextBlock Text="Hello world"
Background="{StaticResource brushExpander}"/>
</Expander.Header>
<Rectangle Height="100"/>
</Expander>
</Grid>
</Window> |
http://img407.imageshack.us/img407/6120/expandertt4.png
En observant le visual tree avec Mole, j'ai vu que la structure était la suivante :
http://img171.imageshack.us/img171/9...ualtreesd0.png
Donc en gros, c'est sur le ToggleButton que je voudrais appliquer le background. Et je ne vois pas trop comment faire ça sans redéfinir entièrement le template de l'Expander :?
Une idée ?