MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.28k stars 2.45k forks source link

Left padding of icon in MenuItem is too less #3439

Closed GF-Huang closed 5 years ago

GF-Huang commented 5 years ago

image

punker76 commented 5 years ago

@GreatFireWall Please, post more informations when you open an issue! https://github.com/MahApps/MahApps.Metro/blob/develop/.github/ISSUE_TEMPLATE/bug_report.md

GF-Huang commented 5 years ago

@punker76 sorry, it may not be a bug ? just the left side edge too less, seems like no edges between Icon and menu item left edge.

image

punker76 commented 5 years ago

@GreatFireWall How do you set these icons? Can you post your Xaml code of this ContextMenu?

GF-Huang commented 5 years ago

@punker76 image

punker76 commented 5 years ago

@GreatFireWall Thx! I see you use the IconPacks extension to set the icon. This is ok, but it doesn't set the horizontal alignement for the inner icon itself. Because the menu style uses the streched enum value for the horizontal alignement. I suggest to use the normal class and not the extension from the IconPacks where you can set the horizontal alignement.

<MenuItem Header="Icon Test">
    <MenuItem Header="Test 1" Icon="{iconPacks:Modern Kind=Connect}" />
    <MenuItem Header="Test 1">
        <MenuItem.Icon>
            <iconPacks:PackIconModern Kind="Connect" HorizontalAlignment="Center" />
        </MenuItem.Icon>
    </MenuItem>
</MenuItem>

2019-01-27_19h22_24

GF-Huang commented 5 years ago

@punker76 Well, Solved ! Thank You !

GF-Huang commented 5 years ago

@punker76 By the way, Can I use style for {iconPacks:Modern xxx} to make it effect all instance while in a ContextMenu, because I want to keep my code as short as possible.

punker76 commented 5 years ago

@GreatFireWall Yes, you can define a global style at the App.xaml or at the main window where you use the IconPacks.

<Style TargetType="{x:Type iconPacks:PackIconModern}" BasedOn="{StaticResource {x:Type iconPacks:PackIconModern}}">
    <Setter Property="HorizontalAlignment" Value="Center" />
</Style>
GF-Huang commented 5 years ago

@punker76 ok, thanks your guide !