我尝试在 WPF 中添加ContextMenu自定义样式以避免这种丑陋的外观(样式在全局范围内应用):TextBox<Setter Property="ContextMenu" Value="{StaticResource ProfessionalContextMenu}" />MenuItem

使用这种ContextMenu风格:
<Style x:Key="ProfessionalContextMenu" TargetType="{x:Type ContextMenu}">
    <Setter Property="Background" Value="Black"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="BorderBrush" Value="#FF494949"/>
    <Setter Property="Padding" Value="1"/>
</Style>
但它会引发异常 (XamlParseException)。