gpt4 book ai didi

windows-phone-7 - WP7 ApplicationBarIcon可见性

转载 作者:行者123 更新时间:2023-12-04 07:21:02 25 4
gpt4 key购买 nike

感谢 WP7 ApplicationBarIcon 本身不是标准控件。

我需要能够以编程方式隐藏它(我需要隐藏而不是禁用)

1/除了添加/删除图标,我还有其他方法可以做到吗

2/假设我必须添加和删除它,我如何将事件关联到我正在添加的控件?

  • 谢谢

最佳答案

如下所示:在代码中创建一个appbar;向其添加一个按钮(包括“点击”事件处理程序);并删除特定按钮。

    this.ApplicationBar = new ApplicationBar();

var newButton = new ApplicationBarIconButton();
newButton.IconUri = new Uri("/images/remove.png", UriKind.Relative);
newButton.Text = "remove";
newButton.Click += RemoveAppBarButton;

this.ApplicationBar.Buttons.Add(newButton);


void RemoveAppBarButton(object sender, EventArgs e)
{
for (var i = 0; i < this.ApplicationBar.Buttons.Count; i++)
{
var button = this.ApplicationBar.Buttons[i] as ApplicationBarIconButton;

if (button != null)
{
if (button.Text == "remove")
{
this.ApplicationBar.Buttons.RemoveAt(i);
break;
}
}
}
}

需要注意的重要一点是,您不能通过名称引用按钮(或菜单项)。

关于windows-phone-7 - WP7 ApplicationBarIcon可见性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6702866/

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