Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MenuItem.Icon won't stretch in Windows 8 as it did in previous OS versions

$
0
0

I have an application that sets MenuItem.Icon as follows:

<MenuItem.Icon>
                    <Image Source="/WpfApplication3;component/Images/doc_import%20.png" Width="31" Height="31" SnapsToDevicePixels="False" />
</MenuItem.Icon>

Under Windows 7, Vista, XP, setting the Image size like this would result in the image being resized. In Windows 8, the image is stretched, but only the top left 16x16 portion is visible. All of my menu bars are unrecognizable in Windows 8. The only workaround is setting the image size back to auto and using negative margins to stretch it larger. This is pretty bad. Has anyone else seen this or know of a fix for it?

Steps to repro:

Create a new WPF project on Windows 8. Replace the default grid with the following:

 

<StackPanel>

        <Menu Height="67">
            <MenuItem Header="Open Existing" Command="NavigationCommands.GoToPage"  CommandParameter="Pages/Open.xaml" CommandTarget="{Binding ElementName=frmContent}" Foreground="White" Margin="4,5,4,1" Padding="0,10,5,2" StaysOpenOnClick="True" Height="50">
                <MenuItem.Icon>
                    <Image Source="/WpfApplication3;component/Images/doc_import%20.png" Width="31" Height="31" SnapsToDevicePixels="False" />
                </MenuItem.Icon>
            </MenuItem>
        </Menu>

    </StackPanel>

Correct your image path and notice what has happened to your image.

Thanks,

Glenn


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>