WPF:奇怪的图像拉伸按钮按钮、图像、奇怪、WPF

由网友(人丑任性)分享简介:我有多个按钮,每一个具有32×32像素的PNG图片。但奇怪的是,这两个按钮显示不同的大小(是的,我三重检查的图标是真正的32×32!)。在秒按钮的样子,这将是48×48像素的大小。最有趣的是,如果我省略了拉伸=无属性,该图标放大来填充几乎整个屏幕。I have multiple buttons, each havin...

我有多个按钮,每一个具有32×32像素的PNG图片。但奇怪的是,这两个按钮显示不同的大小(是的,我三重检查的图标是真正的32×32!)。在秒按钮的样子,这将是48×48像素的大小。最有趣的是,如果我省略了拉伸=无属性,该图标放大来填充几乎整个屏幕。

I have multiple buttons, each having a 32x32 pixels PNG image. The strange thing is, that both buttons show different sizes (Yes, I triple checked that icons are really 32x32!). The seconds button looks like as it would be 48x48 pixels in size. The funniest thing is, if I omit the Stretch="None" attribute, the icons are scaled up to fill nearly the whole screen.

我无法解释自己为什么会这样!

I cannot explain myself why this is happening!

    

    <ToolBar Name="toolBar1" DockPanel.Dock="Top">
        <Button Name="importButton" ToolTip="Import" Click="importButton_Click">
            <Image Source="Icons/Import.png" Stretch="None" />
        </Button>
        <Button Name="toggleDetails" ToolTip="Details for Item" Click="toggleDetails_Click">
            <Image Source="Icons/maximize.png" Stretch="None" />
        </Button>           
    </ToolBar>

    <StackPanel Name="stackPanel1" DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,5,0,5">
        <Label  Name="label2" Content="Find"></Label>
        <TextBox  Name="tags" Width="400" KeyDown="tags_KeyDown" />
        <Button ToolTip="Find" Name="findItemsButton" Click="findItemsButton_Click">
            <Image Source="Icons/xmag.png" Stretch="None" />
        </Button>
        <CheckBox Content="Show Closed" Name="showClosedItemsCheckBox" VerticalAlignment="Center" Margin="10,0,0,0" Click="showClosedItemsCheckBox_Click" />
    </StackPanel>
    <TabControl  Name="tabControl" TabStripPlacement="Top">

    </TabControl>

</DockPanel>

推荐答案

这两个图像可能有不同的DPI。

The two images probably have different DPIs.

阅读全文

相关推荐

最新文章