【问题标题】:Adding Microsoft.Phone.dll to use Applicationbar class gives "Cannot find type System.SystemException in module mscorlib.dll" error添加 Microsoft.Phone.dll 以使用 Applicationbar 类给出“在模块 mscorlib.dll 中找不到类型 System.SystemException”错误
【发布时间】:2016-06-30 17:51:39
【问题描述】:

我目前正在为 Windows Phone 8.1 开发应用程序。添加 Microsoft.Phone.dll 程序集以能够使用 ApplicationBar 和 ApplicationBarIconButton 类后,我遇到以下情况 错误:

Cannot find type System.SystemException in module mscorlib.dll.

在阅读了类似问题(如this)后,Windows Phone 似乎不接受第三方库。

我应该如何在我的 C# 代码中使用上述类?

【问题讨论】:

    标签: c# xaml windows-phone-8.1


    【解决方案1】:

    Microsoft.Phone.dll 旧式 (Silverlight) Windows Phone 库。 在通常的 Windows Phone Store 应用程序中,您应该使用CommandBar 组件。

    示例:How it works

    更新

    <Page.BottomAppBar>
        <CommandBar x:Name="bottomCommandBar">
            <CommandBar.PrimaryCommands>
                <AppBarButton Icon="Account"/>
            </CommandBar.PrimaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
    

    和 C# 代码

        private bool _isAdded;
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!_isAdded)
            {
                var button = new AppBarButton();
                button.Icon = new SymbolIcon(Symbol.Find);
                bottomCommandBar.PrimaryCommands.Add(button);
            }
            else
            {
                bottomCommandBar.PrimaryCommands.RemoveAt(bottomCommandBar.PrimaryCommands.Count - 1);
            }
    
            _isAdded = !_isAdded;
        }
    

    【讨论】:

    • 感谢您的参考,您能否提供一个 c# 代码参考?
    • 您想以编程方式(通过 c#)添加命令栏吗?不在 xaml 中?
    • 嗯,不仅如此,我还需要以编程方式更改应用程序中的按钮,并且可以通过 c# 更改命令栏和按钮的属性。
    • 非常感谢您的礼貌。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-31
    • 1970-01-01
    相关资源
    最近更新 更多