我正在尝试绘制一个在网格文本后面旋转 45° 的矩形,并且网格位于 TreeViewItem 内。到目前为止,没有任何事情可以让它正确......我也一直在尝试使用网格的背景,但那里没有结果。这是到目前为止我得到的代码:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
<Grid Margin="0,5,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Name="rect" Stretch="Uniform" Fill="{StaticResource ItemAreaBrush}"
Stroke="{StaticResource ItemBorderBrush}" StrokeThickness="1">
<Rectangle.RenderTransform>
<RotateTransform CenterX=".5" CenterY=".5" Angle="45" />
</Rectangle.RenderTransform>
</Rectangle>
<ContentPresenter ContentSource="Header" Grid.Row="0" />
<ItemsPresenter Grid.Row="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<!--<Setter TargetName="Bd" Property="Panel.Background" Value="{StaticResource SelectedItemAreaBrush}" />-->
<Setter TargetName="rect" Property="Rectangle.Stroke" Value="{StaticResource SelectedItemBorderBrush}" />
<Setter TargetName="rect" Property="Rectangle.StrokeThickness" Value="2" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
任何人都可以帮助我解决这个问题吗?