<SolidColorBrush x:Key="MenuItemSelectionFill" Color="#A0C3E9"/> <Color x:Key="GlyphColor">#FF444444</Color> <!--SubmenuItem--> <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}"> <Border x:Name="Border" BorderThickness="0"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="Icon" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" /> <ColumnDefinition Width="13" /> </Grid.ColumnDefinitions> <!--图标--> <ContentPresenter x:Name="Icon" Margin="6,0,6,0" VerticalAlignment="Center" ContentSource="Icon" /> <Border x:Name="Check" Width="13" Height="13" Visibility="Collapsed" Margin="6,0,6,0" BorderThickness="1"> <Border.BorderBrush> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="{DynamicResource BorderLightColor}" Offset="0.0" /> <GradientStop Color="{DynamicResource BorderDarkColor}" Offset="1.0" /> </GradientStopCollection> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.BorderBrush> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="{DynamicResource ControlLightColor}" /> <GradientStop Color="{DynamicResource ControlMediumColor}" Offset="1.0" /> </GradientStopCollection> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.Background> <Path x:Name="CheckMark" Width="7" Height="7" Visibility="Hidden" SnapsToDevicePixels="False" StrokeThickness="2" Data="M 0 0 L 7 7 M 0 7 L 7 0"> <Path.Stroke> <SolidColorBrush Color="{DynamicResource GlyphColor}" /> </Path.Stroke> </Path> </Border> <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" /> <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,2,0,2" DockPanel.Dock="Right" /> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="ButtonBase.Command" Value="{x:Null}" /> <Trigger Property="Icon" Value="{x:Null}"> <Setter TargetName="Icon" Property="Visibility" Value="Hidden" /> </Trigger> <Trigger Property="IsChecked" Value="true"> <Setter TargetName="CheckMark" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="IsCheckable" Value="true"> <Setter TargetName="Check" Property="Visibility" Value="Visible" /> <Setter TargetName="Icon" Property="Visibility" Value="Hidden" /> </Trigger> <Trigger Property="IsHighlighted" Value="true"> <Setter Property="Background" TargetName="Border" Value="{StaticResource MenuItemSelectionFill}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>
这里中间会有一跟分割线。这要怎么去掉呢??
贴也来的代码不对
有这个线的代码不这个些,
用blend修改一下样式就行了
我就用了这些代码,谢谢你的回答,这个问题已经解决了,我只是把那个
<Border x:Name="Border"
BorderThickness="0" Background="White"> 加了一个背景颜色为白色,那根竖线就看不到了。