使用its Style和改變這一部分:<Setter Property="Background" Value="Red" />
。請注意,我將其更改爲紅色。
<GridSplitter
HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="50" ResizeBehavior="CurrentAndNext" ShowsPreview="True">
<GridSplitter.Style>
<Style TargetType="controls:GridSplitter">
<Setter Property="Background" Value="#FFFFFFFF" />
<Setter Property="IsTabStop" Value="true" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="PreviewStyle">
<Setter.Value>
<Style TargetType="Control">
<!-- Background -->
<Setter Property="Background" Value="Red" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Control">
<Grid x:Name="Root" Opacity=".5">
<Rectangle Fill="{TemplateBinding Background}" />
<!-- Horizontal Template -->
<Grid x:Name="HorizontalTemplate" Height="6">
<!-- Just show the faint gray grid splitter rectangle with no other details -->
</Grid>
<!-- Vertical Template -->
<Grid x:Name="VerticalTemplate" Visibility="Collapsed" Width="6">
<!-- Just show the faint gray grid splitter rectangle with no other details -->
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:GridSplitter">
<Grid x:Name="Root" IsHitTestVisible="{TemplateBinding IsEnabled}">
<!-- VSM -->
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal" />
<vsm:VisualState x:Name="MouseOver" />
<vsm:VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0" />
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="FocusStates">
<vsm:VisualStateGroup.Transitions>
<vsm:VisualTransition GeneratedDuration="0" />
</vsm:VisualStateGroup.Transitions>
<vsm:VisualState x:Name="Unfocused" />
<vsm:VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<!-- Background -->
<Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" />
<!-- Horizontal Template -->
<Grid x:Name="HorizontalTemplate" Height="10">
<StackPanel Height="6" VerticalAlignment="Center">
<Rectangle Height="1" Margin="1" Width="10" StrokeThickness="0" Fill="#FF868686" />
<Rectangle Height="1" Margin="1" Width="10" StrokeThickness="0" Fill="#FF868686" />
</StackPanel>
</Grid>
<!-- Vertical Template -->
<Grid x:Name="VerticalTemplate" Visibility="Collapsed" Width="10">
<StackPanel Width="6" VerticalAlignment="Center" Orientation="Horizontal">
<Rectangle Width="1" Margin="1" Height="10" StrokeThickness="0" Fill="#FF868686" />
<Rectangle Width="1" Margin="1" Height="10" StrokeThickness="0" Fill="#FF868686" />
</StackPanel>
</Grid>
<!-- Focus Visual -->
<Rectangle x:Name="FocusVisual" Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GridSplitter.Style>
</GridSplitter>
不要忘記在XAML中的XML命名空間的映射:
xmlns:vsm="clr-namespace:System.Windows;assembly=PresentationFramework"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
來源
2017-02-16 01:47:53
Ron
您可能還需要改變混濁的''<電網X:「5" NAME = 「根」 不透明度=> '' – Ron