Colonel Panic
Colonel Panic

Reputation: 137512

What size and format should image for WPF MenuItem Icon be?

What size and format should a WPF MenuItem Icon be to look right?

Right now I have

<ContextMenu>
  <MenuItem Header="Camera">
    <MenuItem.Icon>
      <Image Source="images/camera.png" />
    </MenuItem.Icon>

But in the menu, the icon spills over margin, which looks bad.


Frustratingly, the docs don't give this information. System.Windows.Controls.MenuItem.Icon

Upvotes: 3

Views: 8011

Answers (2)

MikroDel
MikroDel

Reputation: 6735

this is the code:

<MenuItem>
   <MenuItem.Header>
      <StackPanel>
         <Image Width="20" Height="20" Source="PATH to your image" />
       </StackPanel>
   </MenuItem.Header>
</MenuItem>

You can also try stretch Image.Stretch Property

Upvotes: 0

Ionică Bizău
Ionică Bizău

Reputation: 113517

I think that the right size of image would be 20px.

Just specify the Width and the Heigth of your image:

Use this:

<MenuItem.Icon>
  <Image Source="images/camera.png" 
        Width="20"
        Height="20" />
</MenuItem.Icon>
...

Upvotes: 3

Related Questions