按钮图像不可见 [英] Button image not visible

查看:148
本文介绍了按钮图像不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Windows 8.1商店应用,我需要添加一个按钮。
按钮应显示图像。

I'm trying to create a Windows 8.1 store app, and I need to add a button to it. The button should display an image.


  • 我在Solution Exploreras Artwork / Pencil.png中将图像添加到装配中

  • 我将按钮添加到UI

  • 使用按钮的属性编辑器,我选择前景图像。

  • 设计师显示装配中可用图像的列表,我选择图像。

  • 设计师显示所选图像(部分)。

  • 该按钮保持空白。

  • I add the image to the assembly in Solution Exploreras Artwork/Pencil.png
  • I add the button to the UI
  • Using the property editor for the button, I select Foreground image.
  • The designer shows a list of available images from the assembly, I choose the image.
  • The designer shows the selected image (partially).
  • The button remains blank.

我尝试使用不同的内容类型(图像),作为内容,嵌入式资源,不要复制,如果更新则复制。

I tryied playing around with different content types (of the image), as Content, Embedded resource, Do not copy, Copy if newer.

图像在设计或运行时都不可见。

The image is not visible either at design or run time.

我发现关于WPF中的这个问题,从2005年到2012年的大量文章。尝试更改图像源(虽然我认为设计师应该正确设置):

I found tons of articles from 2005 to 2012 about this problem in WPF. Tryed to change the image source (although I think the designer should set it correctly):


  • Pencil.png

  • Artwork / Pencil.png

  • pack:// siteoforigin:,,, / Pencil.png

  • pack:// siteoforigin: ,,, / Artwork / Pencil.png

  • pack:// application:,,, / Pencil.png

  • pack:// application: ,,, / Artwork / Pencil.png

  • Pencil.png
  • Artwork/Pencil.png
  • pack://siteoforigin:,,,/Pencil.png
  • pack://siteoforigin:,,,/Artwork/Pencil.png
  • pack://application:,,,/Pencil.png
  • pack://application:,,,/Artwork/Pencil.png

有任何想法吗?

为了使环境清晰:


  • Visual Studio 2013 Update 2

  • 项目类型:Visual C#/存储应用/ Windows应用/空白应用

  • 目标:Windows 8.1

推荐答案

这是一个既适用于设计时又适用于运行时的程序:

Here's one that works both design-time and runtime:


  • 将其设置为背景图像(与前景相对)

  • 将文件设置为内容,如果更新则复制

  • 使用设计器指定图像(这将生成一个像这个Artwork / Pencil.pn g)

这篇关于按钮图像不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆