Cha*_*lie 14
使用WPF一切皆有可能.;)不幸的是并非所有事情都很简单.这里你最好的选择是重新模板扩展器.首先复制默认Expander模板,在此处找到.
接下来,找到Grid包含2列的列,其中一列包含a ToggleButton,另一列包含a ContentPresenter.交换列,使切换位于第1列.然后更改列定义大小,以便第一列是星号,第二列是大小20.完成后,模板中应该有一个块,如下所示:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<ToggleButton Grid.Column="1"
IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}}"
OverridesDefaultStyle="True"
Template="{StaticResource ExpanderToggleButton}"
Background="{StaticResource NormalBrush}" />
<ContentPresenter Margin="4"
ContentSource="Header"
RecognizesAccessKey="True" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
继续修改模板,直到获得所需的外观.
编辑:MSDN上提供的模板是"真正的"扩展器模板的简单版本.如果您需要风格化的扩展器模板,请使用Expression Blend并复制现有的控件模板Expander.