I want an Expander
that only expands/collapse it's content when the user clicks on the header icon. (Instead of the whole header being clickable.)
Do I have to redefine the control Template
to do this? How would it look l开发者_开发问答ike?
Thanks for your time.
There is actually a much simpler XAML solution than modifying templates. Simply DON'T use the Expander's header property in this case. Instead, cover the expander with your own styled TextBlock.
<Application.Resources>
<Style x:Key="ExpanderHeader" TargetType="{x:Type TextBlock}">
<Setter Property="Height" Value="22" />
<Setter Property="Margin" Value="21,0,0,0" />
<Setter Property="Padding" Value="9,3,0,0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Top" />
</Style>
</Application.Resources>
<Grid>
<Expander>
<TextBlock Text="I am some content. I have disowned my default header." Margin="10,5" />
</Expander>
<TextBlock Text="I'm filling in for the default header. You'll like me better anyway."
Style="{StaticResource ResourceKey=ExpanderHeader}"/>
</Grid>
I posted a solution to my question here (same link as in the comment from Ben).
精彩评论