Windows Phone 7 不显示 ApplicationBar 按钮内的图标

发布于 2024-10-03 13:24:43 字数 1277 浏览 1 评论 0原文

我正在开发我的第一个 Windows Phone 7 应用程序,我必须添加一个带有图标的应用程序栏。

我提到了这个“如何”: http://msdn .microsoft.com/en-us/library/ff431786(VS.92).aspx(“在 XAML 中创建应用程序栏”段落)

但是当我运行模拟器时,我看不到缺点:我看到黑色圆圈中心的 X 和事件 ApplicationBarIconButton_Click 正确引发。

我使用的是 WP7AppBarIcons.zip 示例中的图标,我的代码发布在下面:

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/images/appbar.transport.play.rest.png" Text="Home" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/images/appbar.favs.rest.png" Text="Preferiti" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/images/appbar.questionmark.rest.png" Text="About" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

显然,我有一个名为“images”的根解决方案文件夹,其中包含提到的 48 x 48 图标。

多谢!

I'm developing my first Windows Phone 7 application and I have to add an Application Bar with icons.

I referred to this "How To" : http://msdn.microsoft.com/en-us/library/ff431786(VS.92).aspx ("Creating an Application Bar in XAML" paragraph)

But when I run Emulator I cannot see incons: I see the black circle with X in the center and event ApplicationBarIconButton_Click correctly raised.

I'm using icon from WP7AppBarIcons.zip samples and my code is posted below:

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/images/appbar.transport.play.rest.png" Text="Home" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/images/appbar.favs.rest.png" Text="Preferiti" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/images/appbar.questionmark.rest.png" Text="About" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Obviously, I have a root solution folder named "images" containing the mentioned 48 x 48 icons.

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

木格 2024-10-10 13:24:43

图像构建操作是否设置为“内容”而不是“资源”,因为这是一个常见的错误 - 我自己也这样做过几次。它们需要采用这种方式,因为 ApplicationBar 不是 Silverlight 控件,并且图像需要设置为 Content。

Are the images Build Action set to "Content" rather than "Resource" as this is a common mistake - I've done it a couple of times myself. They need to be this way as ApplicationBar is not a Silverlight control and the images need to be set to Content.

找个人就嫁了吧 2024-10-10 13:24:43

你的 PNG 绝对是 2 色的,只是透明背景上的白色吗? IIRC 如果不是这种情况,他们将不会加载。您可能想从一个可以工作的示例项目中获取一个 PNG,只是为了检查是否是文件内容导致了问题或其他原因。

另外,检查“images”的大小写 - 所有示例都使用“Images”而不是“images”;可能不是问题,但值得检查:)

Are your PNGs definitely 2 colour, just white on a transparent background? IIRC they won't load if that's not the case. You might want to grab a PNG from a sample project which does work, just to check whether it's the file contents that are causing the problem or something else.

Also, check the case of "images" - all the samples use "Images" instead of "images"; probably not what's wrong, but worth checking :)

千鲤 2024-10-10 13:24:43

您可以右键单击该项目然后>添加>现有项目,然后添加符合 Jon Skeet 先生在上述答案中提到的标准的 .png 图像。

之后,您应该会发现图像出现在解决方案资源管理器中,右键单击解决方案资源管理器中的图像>;然后,属性将“构建操作”属性更改为“内容”,

希望这能

顺利进行

you can right click on the project then > Add > Existing Item , Then add your .png image that meets the criteria that mr Jon Skeet mentioned in the above answer.

after that you should find the the image appear in the solution explorer , right click on the image from the solution explorer > Properties then change the 'Build Action' property to 'Content'

hope this works

peace

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文