自定义 Visual Studio 工具 window 中的图像图标看起来格式不正确 (VSIX)

Image icons do not look well formed in Custom Visual Studio tool window (VSIX)

我正在从事 VSIX(Visual Studio 扩展)项目。它包含一个显示信息的工具window。

工具 windows 是基于 walkthrough 创建的,随后在 MSDN 中。

我观察到添加到工具 window 中的图像图标(根据我的测试为 Png、jpg 格式)看起来格式不正确(不是原始外观),有时我更改大小时或工具的位置 window(通过拖放、停靠和取消停靠)。

使用的图像图标:Cross.png

修改了 FirstToolWindowControl.xaml 的源代码(按照上述 walkthrough

<UserControl x:Class="FirstToolWin.FirstToolWindowControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             Background="{DynamicResource VsBrush.Window}"
             Foreground="{DynamicResource VsBrush.WindowText}"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             Name="MyToolWindow">
    <Grid Width="auto" Height="auto">       
        <Image Margin="20" Source="C:\Cross.png" Width="16" Height="16" HorizontalAlignment="Center"  />
    </Grid>
</UserControl>

格式错误的图像屏幕截图:MalformedImageIcon.png

感谢任何人帮助找到根源并解决问题。 谢谢。

一个我能正常显示的解决方案:

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" >
        <Image Width="16" Height="16" RenderOptions.BitmapScalingMode="NearestNeighbor"
   RenderOptions.EdgeMode="Aliased">
            <Image.Source>
                <BitmapImage DecodePixelWidth="200"  UriSource="C:\Users\xxx\source\repos\ColeVSIXProject\ColeVSIXProject\Resources\Test2.png" /> 
            </Image.Source>
        </Image>
    </StackPanel> 

使用基于 XAML 的矢量图像而不是光栅图像图标。我们能够从 this 存储库中找到大多数 Standerd 图标(基于 XAML)。