Skip to content

Commit

Permalink
Context menu is unreadable when dark theme #142
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Mar 11, 2024
1 parent a0651b0 commit a1abc7f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CodeNav.Shared/CodeNav.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Styles\ContextMenuStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Styles\PlusMinusExpanderStyles.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
4 changes: 3 additions & 1 deletion CodeNav.Shared/Menus/ItemContextMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Styles/BookmarkButtonStyle.xaml"/>
<ResourceDictionary Source="../Styles/ContextMenuStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>

<ContextMenu
x:Key="ItemContextMenu"
IsOpen="{Binding Path=ContextMenuIsOpen, Mode=TwoWay}">
IsOpen="{Binding Path=ContextMenuIsOpen, Mode=TwoWay}"
Style="{StaticResource ContextMenuStyle}">

<MenuItem
Header="Go to Definition"
Expand Down
49 changes: 49 additions & 0 deletions CodeNav.Shared/Styles/ContextMenuStyle.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vsShell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0">

<Style x:Key="ContextMenuStyle" TargetType="{x:Type ContextMenu}">
<Setter Property="Background" Value="{DynamicResource {x:Static vsShell:EnvironmentColors.DropDownPopupBackgroundBeginBrushKey}}" />
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static vsShell:EnvironmentColors.DropDownBorderBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell:EnvironmentColors.ToolWindowTextBrushKey}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border Uid="Border_93">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Tag" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="0,0,5,5"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4" Opacity="0.8" ShadowDepth="1"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Uid="Border_50">
<ScrollViewer CanContentScroll="True"
Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer,
TypeInTargetAssembly={x:Type FrameworkElement}}}"
Uid="ScrollViewer_9">
<ItemsPresenter
KeyboardNavigation.DirectionalNavigation="Cycle"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Uid="ItemsPresenter_5"/>
</ScrollViewer>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

0 comments on commit a1abc7f

Please sign in to comment.