【问题标题】:Appbar Button icon image seems not correct in Window 8.1Appbar 按钮图标图像在 Window 8.1 中似乎不正确
【发布时间】:2014-02-28 06:05:36
【问题描述】:

我使用 BitMapIcon 创建了一个 appbar 按钮。下面是代码

<AppBarButton HorizontalAlignment="Stretch" Label="AppBarButton" VerticalAlignment="Stretch" Background="White" Foreground="White">
    <AppBarButton.Icon>
        <BitmapIcon UriSource="Assets/work.png"/>
    </AppBarButton.Icon>
</AppBarButton>

work.png 是按钮图像。但 appbar 按钮图像似乎与原始工作图像不同。查看图片

第二张图片是40 x 40尺寸图片的原始图标,我将背景设置为黑色用于显示[work.png]
怎么做才能像原始图标一样正确显示按钮图标?或者这种不匹配的原因是什么?

appbar 按钮是否允许半透明图标图像?

【问题讨论】:

  • 在我看来,它以错误的大小对其进行解码,并且混叠是导致问题的原因。是否可以将该图标作为路径?根据 Tim Heuer here 的说法,他们正在使用 BitmapIcons 找到一些非常不理想的实例,尤其是像您那里那样的精细细节。
  • @NateDiamond 是的。最后我使用了 svg 图像中的路径数据,我得到了正确的结果。但是对于某些 svg 图像,其中包含多个路径数据。我们如何使用它?
  • 所以,PathIconData 属性是Geometry,其中一个子类是漂亮的GeometryGroup 类。这将允许您创建多个 PathGeometrys 作为孩子。
  • 最后我用路径替换了 png 图片。

标签: xaml windows-runtime microsoft-metro winrt-xaml windows-8.1


【解决方案1】:

我遇到了类似的问题,发现将高度和宽度设置为 png 阻止了它。
注意: 40x40 对于圆圈来说似乎太大了。

<AppBarButton HorizontalAlignment="Stretch" Label="AppBarButton" VerticalAlignment="Stretch" Background="White" Foreground="White">
    <AppBarButton.Icon>
        <BitmapIcon UriSource="Assets/work.png" Height="20" Width="20"/>
    </AppBarButton.Icon>
</AppBarButton>

【讨论】:

    【解决方案2】:

    我遇到过类似的事情。原始 PNG 上的 Alpha 值似乎存在问题。通常,附加到白色像素的 Alpha 值可以为您提供一种在深色背景下的灰度图像,提供比单色图像更多的细节。也就是说,您的原始 PNG 可能由所有白色像素组成,但具有被 BitmapImage 控件破坏的 Alpha 值。我找到了两个选择。您可以转到原始 PNG 并删除 alpha 值不是 0 或 255 的像素,也可以重新模板化 AppBarButton 以使用 Image 控件而不是 BitmapIcon。我认为 BitmapIcon 是脑残,选择了后者,这并不算太糟糕,因为原始模板可以在以下位置找到:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn481531.aspx

    【讨论】:

    • 感谢您的帮助,我为图像创建了路径数据并在 PathIcon 中使用了它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 2015-06-28
    相关资源
    最近更新 更多