windows-phone-7 - WP7 ApplicationBarIcon可见性

标签 windows-phone-7 icons visibility

感谢 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/

相关文章:

c# - "Element is already the child of another element."

c# - Windows Phone 上的状态大小

typescript - 将 CoreUI 图标导入 Vue.js TypeScript 项目

c++ - 如何从可执行文件的资源中提取48*48的图标图像?

javascript - 页面加载时默认隐藏所有div,显示:none doesn't appear to work

html - 如何使用显示属性更改特定元素的可见性 (html/php)

windows-phone-7 - Windows Phone 7编程USB端口的使用

css - 将 Material 图标与 Materialise 上的文本对齐

android - 切换 View 可见性

c# - Windows Phone 7 - App.ViewModel 重复项