如何改变从C#中的应用程序任务栏的形象呢? [英] How to change the image on the ApplicationBar from C#?

查看:130
本文介绍了如何改变从C#中的应用程序任务栏的形象呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,有一个应用程序任务栏的小C#项目。但我有一个小问题:我想在酒吧8图标和应用程序任务栏仅支持4我想出了一个解决方案(在C#):​​添加一个小的复选框,问,如果用户要使用第一或第二组工具。

但我还是不能够改变对应用程序任务栏的图标。我试着删除旧的,先用 ApplicationBar.MenuItems.Remove(Button1的); ,然后用 ApplicationBar.Buttons.Remove(Button1的);
,但既不工作。我试图改变按钮的 .IconUri 属性,但是这给了我一个NullReferenceException。

I have a small C# project that has an ApplicationBar. But I have a small problem: I want 8 icons on the bar, and the ApplicationBar only supports 4. I came up with a solution (in C#): add a small CheckBox to ask if the user wants to use the first or second set of tools.

But I'm still not able to change the icons on the ApplicationBar. I tried removing the old ones, first with ApplicationBar.MenuItems.Remove(Button1); and then with ApplicationBar.Buttons.Remove(Button1); but neither worked. I tried changing the .IconUri property of the button, but that gave me a NullReferenceException.

推荐答案

我不明白你从C#,不是Silverlight的更改它的意思。 C#是一种编程语言和Silverlight是一个框架。不过,你要贴的链接解释正是你怎么做。该应用程序任务栏不是Silverlight控件,它的原生操作系统的一部分。您可以使用代码的链接,或做这样的事:

I don't understand what you mean by changing it from "C#, not Silverlight". C# is a programming language and Silverlight is a framework. Nevertheless, the link you posted to explains exactly how you do it. The ApplicationBar is not a Silverlight control, it's part of the native OS. You can use the code in the link or do something like this:

firstAppBarButton = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
firstAppBarButton.Text = "New Text";
firstAppBarButton.IconUri = new Uri("/appbarIcon.png",UriKind.Relative);

您需要获得 ApplicationBarIconButton 通过指数(0表示第一个,1秒等)而不是按名称。

You need to get the ApplicationBarIconButton via the index (0 for first one, 1 for second etc..) instead of by name.

这篇关于如何改变从C#中的应用程序任务栏的形象呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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