选定的TabItem中的图像不清晰

Mat*_*ias 11 wpf icons tabcontrol ico tabitem

我有一个TabControl.每个TabItem的标题包含一个带有图标和Label的StackPanel.

<TabControl>
  <TabItem>
    <TabItem.Header>
      <StackPanel Orientation="Horizontal">
        <Image Source="/LoginPanel;component/Icons/icoLogin.ico"</Image>
        <Label VerticalContentAlignment="Center">Login</Label>
        </StackPanel>
      </TabItem.Header>
    </TabItem.Header>
    <!--some further code here-->
  <TabItem>
  <!--some further code here-->
<TabControl>
Run Code Online (Sandbox Code Playgroud)

每个未选择的TabItem中的每个图标都按预期显示.当前所选TabItem中的图标有些混浊.如果我切换到另一个标签,取消选择的标签图标变得清晰; 新选择的图标变为阴天.

我已经尝试过以下方法来解决这个问题:

SnapsToDevicePixels="True"
Run Code Online (Sandbox Code Playgroud)

但没有任何反应

要么

Width="32" Height="32"
Run Code Online (Sandbox Code Playgroud)

要么

Stretch="None"
Run Code Online (Sandbox Code Playgroud)

防止缩放.所有这些都没有任何影响.有人可以给我一个提示吗?提前致谢

Mar*_*kus 14

这对我有用:

<Image Source="/LoginPanel;component/Icons/icoLogin.ico"
       RenderOptions.BitmapScalingMode="NearestNeighbor"</Image>
Run Code Online (Sandbox Code Playgroud)


Jen*_*ens 10

考虑将'RenderOptions.EdgeMode'设置为'Aliased'.

<Image Source="/LoginPanel;component/Icons/icoLogin.ico"
       RenderOptions.BitmapScalingMode="NearestNeighbor"
       RenderOptions.EdgeMode="Aliased"/> 
Run Code Online (Sandbox Code Playgroud)

请参阅WPF中的图像,在此处获取blury.