What size and format should the WPF MenuItem Icon be?

What size and format should the WPI MenuItem have?

Now I have

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

      

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


Frustratingly, the docs do not provide this information. System.Windows.Controls.MenuItem.Icon

+3


source to share


2 answers


I think the correct image size would be 20px

.

Simply point Width

and Heigth

your image:



Use this:

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

      

+3


source


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 to stretch Image.Stretch Property

0


source







All Articles