【发布时间】:2018-06-07 14:49:30
【问题描述】:
我正在开发一个 VSIX(Visual Studio 扩展)项目。它包含一个显示信息的工具窗口。
工具窗口是基于 MSDN 中的 walkthrough 创建的。
我观察到添加到工具窗口的图像图标(根据我的测试,Png、jpg 格式)看起来格式不正确(不是原始外观),有时当我更改工具窗口的大小或位置时(通过拖放、停靠和取消停靠)。
使用的图片图标: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
感谢任何人帮助找到根本课程并解决问题。 谢谢。
【问题讨论】:
-
M,你想在哪里添加这个图标?
-
在作为上述工具窗口一部分的堆栈面板中。
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" Orientation="Horizontal"> <Label Content="You can view this..."/> <Button Margin="1,0" Cursor="Hand" BorderBrush="Transparent" BorderThickness="0" Command="{Binding SomeCommand}" CommandParameter="{Binding SelectedItem.Lot}" Background="Transparent"> <Image Source="cross.png" HorizontalAlignment="Left" /> </Button> </StackPanel> -
@JackZhai-MSFT,我们还尝试了矢量(基于 XAML)和光栅图像。观察到相同的行为。
-
@JackZhai-MSFT,感谢您对此的任何反馈 :)
标签: wpf visual-studio-extensions vsix