2014-06-11 142 views

回答

4

Tha AppBarButtonIconIconElement类型,所以你不能只是把那里string。如果你想使用一个Symbol你可以做这样的:

PinToStart.Icon = new SymbolIcon(Symbol.UnPin); //instead of "Pin" 

但我而只交换图标遇到了一些问题。我不确定在更新后他们是否还在那里。如果是这样,我建议在代码交换这样的交换整个`AppBarButton

private AppBarButton pin 
{ 
    get 
    { 
     AppBarButton temp = new AppBarButton() { Icon = new SymbolIcon(Symbol.Pin) }; 
     temp.Label = "Pin"; 
     temp.Click += Pin_Click; 
     return temp; 
    } 
} 

private AppBarButton unPin 
{ 
    get 
    { 
     AppBarButton temp = new AppBarButton() { Icon = new SymbolIcon(Symbol.UnPin) }; 
     temp.Label = "UnPin"; 
     temp.Click += UnPin_Click; 
     return temp; 
    } 
} 

然后:

(BottomAppBar as CommandBar).PrimaryCommands[0] = pin; // assign the whole button when Pin/unPin 
+0

好了,第一个解决方案似乎工作,或者我可以只让两个按钮XAML和 if(SecondaryTile.Exists(ItemId)) PinToStart.Visibility = Visibility.Collapsed; UnpinFromStart.Visibility = Visibility.Visible; } –

+0

@ user3393663那么,对 - 我假设你问的应用程序栏按钮:)。当你在XAML中运行普通的Button时,就忘了第二部分,正如你所说的第一部分就足够了。改变可见性应该可行。另请注意,您可以将Button的Content定义为'SymbolIcon',那么不需要从代码中设置它。 – Romasz

+0

是的,他们是AppBarButtons :)。谢谢。 –

0

在Windows Phone 8.1中,没有符号表示'UnPin'

但是你可以让你Pin ButtonAppBarToggleButton。当它被固定时,您可以使'Pin Button'选中。而当它没有固定,你可以使'Pin Button'UnChecked