これが私のボタンテンプレートです。
<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>
今、あなたはこの質問に従って見ることができます私の画像は私が試したStackOverflowでぼやけています..
RenderOptions.BitmapScalingMode="NearestNeighbor"
すべてのレベルで、グリッド、クローム..、SnapsToDevicePixelsのさまざまな組み合わせを試しましたが、画像が正しく表示されません。Stretch = Noneを設定しましたが、画像は中央に配置されますが、それでも自動的に拡大するのはなぜですか?
これが出力であり、非常に苛立たしいものです。
WPFの悪い画像http://akashkava.com/blog/wp-content/uploads/2009/12/BadButton.PNG
画像の実際のサイズは16x16ですが、Windows Maginifierを使用して、画像は実際には20x20としてレンダリングしようとしていることがわかりました。大きな画像の場合は、右端と下部がトリミングされます。Stretch = Noneの場合、画像は16x16で正しくレンダリングされるはずだと思いますが、ここで問題を明確にできる人はいますか?