gpt4 book ai didi

c# - 无法将字符串转换为 Windows.UI.Xaml.Controls.IconElement

转载 作者:行者123 更新时间:2023-11-30 14:55:58 25 4
gpt4 key购买 nike

我找不到如何使用 SymbolIcon.Symbol更改应用栏图标...

这是为了了解我需要做什么:

if (SecondaryTile.Exists(ItemId))
{
PinToStart.Icon = "UnPin"; //instead of "Pin"
}

最佳答案

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

关于c# - 无法将字符串转换为 Windows.UI.Xaml.Controls.IconElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24174005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com