Cowwando
Cowwando

Reputation: 460

Increase size of MenuItem.Icon WPF

I have the following struggle that i did not find solution anywhere on the internet. I have the following menu in WPF application

<Menu  Margin="0,0,95,207" FontSize="14">
        <Menu.Resources>
            <Style TargetType="Image">
                <Setter Property="Height" Value="20" />
                <Setter Property="Width" Value="20" />
                <Setter Property="Stretch" Value="Fill"/>
            </Style>
        </Menu.Resources>
        <MenuItem Header="_File" Height="35" Width="55" ScrollViewer.VerticalScrollBarVisibility="Disabled" Grid.IsSharedSizeScope="True" Padding="5,0" ScrollViewer.CanContentScroll="True" UseLayoutRounding="False">
            <MenuItem.Icon>
                <Image Source="pack://siteoforigin:,,,/Resources/text-icon.png" />
            </MenuItem.Icon>
            <MenuItem Header="_Text" Margin="0">
                <MenuItem.Icon>
                    <Image Source="pack://siteoforigin:,,,/Resources/Power - Shut Down.png"  Margin="0,0,0,0"/>
                </MenuItem.Icon>
            </MenuItem>
        </MenuItem>
    </Menu>

Whatever i try to modify or resize i cannot make the Icons of the menu bigger, nor by menuitem Height, nor by menuitem font-size. I want my icons to be at least 25x25. I guess its the column's size that appear on the left, but i don't know its name/properties so i resize it. Thanks in advance! :)

Upvotes: 2

Views: 3490

Answers (3)

Try this

<MenuItem Height="32" Header="_Text" Margin="0">
   <MenuItem.Icon>
      <Image Source="pack://siteoforigin:,,,/Resources/Power - Shut Down.png" Margin="-2,-2,-2,-2"/>//use negative margin abd item height
   </MenuItem.Icon>
</MenuItem>

Upvotes: 2

Andrea Antonangeli
Andrea Antonangeli

Reputation: 1262

Having the same problem, I ended with using a StackPanel containing the Image and a Label. Avoiding MenuItem.Icon was a relief, beacause it is too complex to customize when needed.

Using the Label allows me to use keyboard shortcuts like the underscore.

        <MenuItem x:Name="mnuMyMenu" BorderThickness="2,0" Padding="4,0" Foreground="Yellow" ToolTip="A nice tooltip.">
            <MenuItem.Header>
                <StackPanel Orientation="Horizontal">
                    <Image Width="32" Height="32" Source="pack://siteoforigin:,,,/Resources/text-icon.png" />
                    <Label Content="_MyMenu with a big icon" BorderThickness="2,0" Padding="4,0" Foreground="Red" >
                    </Label>
                </StackPanel>
            </MenuItem.Header>
        </MenuItem>

Now I can finally have a menu icon big as I wish that fits as I wish.

Upvotes: 0

Muds
Muds

Reputation: 4116

Its not as simple as it should be really, I did it once, by hacking load event. you can try that or Find it here

Upvotes: 0

Related Questions