I couldn't find how to use the SymbolIcon.Symbol to change an appbar icon...
This is to understand what I need to do:
if (SecondaryTile.Exists(ItemId))
{
PinToStart.Icon = "UnPin"; //instead of "Pin"
}
Tha AppBarButton
's Icon is IconElement
type so you cannot just put there a string
. If you want to use a Symbol you can do it like this:
PinToStart.Icon = new SymbolIcon(Symbol.UnPin); //instead of "Pin"
But I've encountered some problems while exchanging only Icons. I'm not sure if they are still there after some updates. If they are, I suggest to exchange the whole `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;
}
}
Then in the code exchange like this:
(BottomAppBar as CommandBar).PrimaryCommands[0] = pin; // assign the whole button when Pin/unPin
In Windows Phone 8.1, there are no Symbol means 'UnPin'
.
But you can make you Pin Button
as AppBarToggleButton . When it has pinned, you can make 'Pin Button'
Checked . And when it has not pinned, you can make 'Pin Button'
UnChecked .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.