2014-06-11 143 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