有人能告诉我为什么紫色路径与第二条路径的比例不同吗?它们在切换按钮的控制模板中设置,如下所示。此外,您可以在此处查看结果:
http://picpaste.com/weird_path-nxRoeKjb.jpg
<Grid x:Name="ToggleButtonGrid"
Background="Navy"
>
<Path x:Name="ExpandPath"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Fill"
Fill="Gray"
Stroke="Purple"
Data="M 0 0 L 12 0 L 12 12 L 0 12 Z" />
<Path
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="Gray"
Stretch="Fill"
Stroke="Yellow"
Data="M 0 6 L 12 6 Z" />
</Grid>
然后在树视图的控件模板中设置。我不明白为什么要调整大小。它们都只是包含在一个网格中。我希望网格可以调整大小,但我得到了这个
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="TreeViewExpanderColumn" MinWidth="19"
Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ToggleButton x:Name="Expander"
Style="{StaticResource ExpandCollapseToggleStyle}"
IsChecked="{Binding Path=IsExpanded,
RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press"/>
<Border Name="Bd"
Grid.Column="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
Padding="0">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Border>
<ItemsPresenter
x:Name="ItemsHost"
Margin="-19,0,0,0"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"/>