wpf - 所选 TabItem 中的图像不清晰

标签 wpf icons tabcontrol tabitem ico

我有一个 TabControl。每个 TabItem 的标题都包含一个带有图标和标签的 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>

每个未选择的 TabItem 中的每个图标都按预期显示。当前选中的 TabItem 中的 Icon 有点模糊。如果我切换到另一个选项卡,取消选择的选项卡图标会变得清晰;新选择的图标变得模糊。

我已经尝试了以下方法来解决这个问题:
SnapsToDevicePixels="True"

但什么也没发生

或者
Width="32" Height="32"

或者
Stretch="None"

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

最佳答案

这对我有用:

<Image Source="/LoginPanel;component/Icons/icoLogin.ico"
       RenderOptions.BitmapScalingMode="NearestNeighbor"</Image>

关于wpf - 所选 TabItem 中的图像不清晰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5401141/

相关文章:

html - 代表图例或图表键的好图标是什么?

wpf - 在Catel MVVM WPF中使用TabControl时的性能

c# - 我可以在 Linux 中编译 .net Core 3 WPF 应用程序吗?

c# - 从项目目录加载 XML 文件

windows - 为什么我看不到在我的 Windows 程序中编译为二进制资源的图标?

c# - 使用 silverlight 的带有可滚动 tabitems 的 Tabcontrol

vb.net - TabPage选择,重新选择TabPage时将Focus移至上一个ActiveControl

.net - 列表框刷新的 MVVM 出现问题

c# - 在单独的线程上显示 WPF -"NotifyIcon"

c# - 选择 System.Drawing.Icon 的大小?