这是我的按钮模板,
现在,根据这个问题My Images are blurry on StackOverflow,我尝试了...
在所有级别上,网格、chrome...并尝试各种SnapsToDevicePixels的组合,但图像仍然无法正确显示。我设置Stretch=None,图像位于中心对齐,但为什么它会自动拉伸?
这是输出,非常令人沮丧。 WPF上的错误图像 http://akashkava.com/blog/wp-content/uploads/2009/12/BadButton.PNG 实际图像大小为16x16,但我通过使用Windows Maginifier发现,无论我做什么,图像实际上都在尝试呈现为20x20,对于更大的图像,甚至会裁剪右侧和底部部分。我认为当Stretch=None时,图像应该以16x16的正确尺寸呈现,有人能澄清这里的问题吗?
<Microsoft_Windows_Themes:ButtonChrome
x:Name="Chrome"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
RenderDefaulted="{TemplateBinding IsDefaulted}"
RenderMouseOver="{TemplateBinding IsMouseOver}"
RenderPressed="{TemplateBinding IsPressed}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image
Source="{TemplateBinding ImageSource}"
RenderOptions.BitmapScalingMode="NearestNeighbor"
SnapsToDevicePixels="True"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="None"
/>
<ContentPresenter
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
RecognizesAccessKey="True"/>
</Grid>
</Microsoft_Windows_Themes:ButtonChrome>
现在,根据这个问题My Images are blurry on StackOverflow,我尝试了...
RenderOptions.BitmapScalingMode="NearestNeighbor"
在所有级别上,网格、chrome...并尝试各种SnapsToDevicePixels的组合,但图像仍然无法正确显示。我设置Stretch=None,图像位于中心对齐,但为什么它会自动拉伸?
这是输出,非常令人沮丧。 WPF上的错误图像 http://akashkava.com/blog/wp-content/uploads/2009/12/BadButton.PNG 实际图像大小为16x16,但我通过使用Windows Maginifier发现,无论我做什么,图像实际上都在尝试呈现为20x20,对于更大的图像,甚至会裁剪右侧和底部部分。我认为当Stretch=None时,图像应该以16x16的正确尺寸呈现,有人能澄清这里的问题吗?