How to change the image on the ApplicationBar from C#?

前端 未结 3 1531
长情又很酷
长情又很酷 2021-01-21 14:31

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 (i

3条回答
  •  故里飘歌
    2021-01-21 14:56

    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);
    

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

提交回复
热议问题