作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
感谢 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/
我是一名优秀的程序员,十分优秀!