Skip to content

Commit

Permalink
(chocolateyGH-685) Fix MahApps MenuItem override
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Mar 2, 2021
1 parent 317bf65 commit 94cad78
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
<Setter Property="mah:HeaderedControlHelper.HeaderFontSize" Value="36.4" />
<Setter Property="mah:HeaderedControlHelper.HeaderFontWeight" Value="Normal" />
<Setter Property="mah:HeaderedControlHelper.HeaderForeground" Value="{DynamicResource MahApps.Brushes.Gray1}" />
<!-- <Setter Property="Margin" Value="0 16" /> -->
<Setter Property="FontFamily" Value="{DynamicResource MahApps.Fonts.Family.Control}" />
<Setter Property="FontSize" Value="{DynamicResource MahApps.Font.Size.Default}" />
<Setter Property="Foreground" Value="{DynamicResource BodyColorBrush}" />
Expand Down
68 changes: 30 additions & 38 deletions Source/ChocolateyGui.Common.Windows/Resources/Controls.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:custom="http://metro.mahapps.com/winfx/xaml/shared"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:properties="clr-namespace:ChocolateyGui.Common.Properties;assembly=ChocolateyGui.Common"
xmlns:converters="clr-namespace:ChocolateyGui.Common.Windows.Utilities.Converters"
xmlns:items="clr-namespace:ChocolateyGui.Common.Windows.ViewModels.Items"
Expand Down Expand Up @@ -70,32 +69,34 @@
Data="{DynamicResource RightArrow}"
Fill="{DynamicResource MahApps.Brushes.RightArrowFill}" />
</Grid>
<Popup x:Name="PART_Popup"
AllowsTransparency="True"
Focusable="False"
HorizontalOffset="-2"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
VerticalOffset="-3">
<Grid>
<Rectangle x:Name="LayoutRoot" Fill="{TemplateBinding Background}" />
<ContentControl x:Name="SubMenuBorder"
IsTabStop="False"
Template="{DynamicResource {ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<ScrollViewer x:Name="SubMenuScrollViewer"
CanContentScroll="True"
Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<ItemsPresenter x:Name="ItemsPresenter"
Margin="0"
Grid.IsSharedSizeScope="True"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</ContentControl>
</Grid>
</Popup>
<Grid Margin="2 0 1 0">
<Popup x:Name="PART_Popup"
AllowsTransparency="True"
Focusable="False"
HorizontalOffset="-1"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
VerticalOffset="-3">
<Grid x:Name="SubMenuRoot">
<Rectangle x:Name="LayoutRoot" Fill="{TemplateBinding Background}" />
<ContentControl x:Name="SubMenuBorder"
IsTabStop="False"
Template="{DynamicResource {ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<ScrollViewer x:Name="SubMenuScrollViewer"
CanContentScroll="True"
Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<ItemsPresenter x:Name="ItemsPresenter"
Margin="0"
Grid.IsSharedSizeScope="True"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</ContentControl>
</Grid>
</Popup>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="True">
Expand All @@ -109,17 +110,8 @@
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
<Setter TargetName="LayoutRoot" Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4"
Direction="315"
Opacity="0.3"
ShadowDepth="2"
Color="{DynamicResource MahApps.Colors.MenuShadow}" />
</Setter.Value>
</Setter>
<Setter TargetName="LayoutRoot" Property="Margin" Value="0 0 6 6" />
<Setter TargetName="SubMenuBorder" Property="Margin" Value="0 0 6 6" />
<Setter TargetName="LayoutRoot" Property="Effect" Value="{DynamicResource MahApps.DropShadowEffect.Menu}" />
<Setter TargetName="SubMenuRoot" Property="Margin" Value="0 0 6 6" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Bg" Property="Fill" Value="{DynamicResource MahApps.Brushes.MenuItem.SelectionFill}" />
Expand Down
16 changes: 6 additions & 10 deletions Source/ChocolateyGui.Common.Windows/Views/PackageView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</Border>
</Grid>

<StackPanel DockPanel.Dock="Left" Margin="20,0,0,0">
<StackPanel DockPanel.Dock="Left" Margin="20 0 0 0">
<controls:InternetImage AutomationProperties.Name="Package Icon"
IconUrl="{Binding IconUrl, IsAsync=True}"
Width="100" Height="100"
Expand Down Expand Up @@ -163,27 +163,23 @@
Style="{StaticResource PackageResourceValue}"
Visibility="{Binding IsPackageSizeAvailable, Converter={StaticResource BoolToVis}}"/>

<StackPanel Margin="5,5,0,40">
<TextBlock
Visibility="{Binding ProjectUrl, Converter={StaticResource UriToVisibilty}}">
<StackPanel Margin="5 5 0 40">
<TextBlock Visibility="{Binding ProjectUrl, Converter={StaticResource UriToVisibilty}}">
<Hyperlink NavigateUri="{Binding ProjectUrl, TargetNullValue=about:blank}" RequestNavigate="HandleLinkClick">
<Run Text="{x:Static properties:Resources.PackageView_ProjectSite}" />
</Hyperlink>
</TextBlock>
<TextBlock
Visibility="{Binding LicenseUrl, Converter={StaticResource UriToVisibilty}}">
<TextBlock Visibility="{Binding LicenseUrl, Converter={StaticResource UriToVisibilty}}">
<Hyperlink NavigateUri="{Binding LicenseUrl, TargetNullValue=about:blank}" RequestNavigate="HandleLinkClick">
<Run Text="{x:Static properties:Resources.PackageView_License}" />
</Hyperlink>
</TextBlock>
<TextBlock
Visibility="{Binding GalleryDetailsUrl, Converter={StaticResource UriToVisibilty}}">
<TextBlock Visibility="{Binding GalleryDetailsUrl, Converter={StaticResource UriToVisibilty}}">
<Hyperlink NavigateUri="{Binding GalleryDetailsUrl, TargetNullValue=about:blank}" RequestNavigate="HandleLinkClick">
<Run Text="{x:Static properties:Resources.PackageView_Gallery}" />
</Hyperlink>
</TextBlock>
<TextBlock
Visibility="{Binding ReportAbuseUrl, Converter={StaticResource UriToVisibilty}}">
<TextBlock Visibility="{Binding ReportAbuseUrl, Converter={StaticResource UriToVisibilty}}">
<Hyperlink NavigateUri="{Binding ReportAbuseUrl, TargetNullValue=about:blank}" RequestNavigate="HandleLinkClick">
<Run Text="{x:Static properties:Resources.PackageView_ReportAbuse}" />
</Hyperlink>
Expand Down

0 comments on commit 94cad78

Please sign in to comment.