the*_*uts 3 c# winrt-xaml windows-phone-8.1
我找不到如何使用SymbolIcon.Symbol更改appbar图标...
这是为了理解我需要做什么:
if (SecondaryTile.Exists(ItemId))
{
PinToStart.Icon = "UnPin"; //instead of "Pin"
}
Run Code Online (Sandbox Code Playgroud)
Tha AppBarButton的Icon是IconElement类型,所以你不能只是把它放在那里string.如果你想使用一个符号你可以这样做:
PinToStart.Icon = new SymbolIcon(Symbol.UnPin); //instead of "Pin"
Run Code Online (Sandbox Code Playgroud)
但是我在交换图标时遇到了一些问题.经过一些更新,我不确定他们是否还在那里.如果是,我建议交换整个`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;
}
}
Run Code Online (Sandbox Code Playgroud)
然后在这样的代码交换中:
(BottomAppBar as CommandBar).PrimaryCommands[0] = pin; // assign the whole button when Pin/unPin
Run Code Online (Sandbox Code Playgroud)