Вы должны настроить TreeViewItem ControlTemplate, изменив столбец ToggleButton. Затем вы можете просто изменить контрольную таблицу с помощью DataTrigger внутри стиля.
<Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
<!-- snip -->
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="19" Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ToggleButton Grid.Column="1" x:Name="Expander"
Style="{StaticResource ExpandCollapseToggleStyle}"
IsChecked="{Binding Path=IsExpanded,
RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press"/>
<Border Name="Bd"
Grid.Column="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Border>
<ItemsPresenter x:Name="ItemsHost"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"/>
</Grid>
<ControlTemplate.Triggers>
<!-- snip -->
</ControlTemplate.Triggers>
</ControlTemplate>
</Style>
Thanks. Вот как я попробовал. Но проблема в том, что на подэлементах (те, что идут в ItemsPresenter), у них тоже есть кнопка расширения справа ... – user1130329
Просто установите шаблон внутри datatrigger, привязанный к свойству уровня вашего объекта – mathieu
Вы имеете в виду I должен переключить CONTROLtemplate внутри datatrigger? – user1130329