添加 Microsoft.Phone.dll 以使用 Applicationbar class 给出 "Cannot find type System.SystemException in module mscorlib.dll" 错误

Adding Microsoft.Phone.dll to use Applicationbar class gives "Cannot find type System.SystemException in module mscorlib.dll" error

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

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

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

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

Microsoft.Phone.dll 旧式 (Silverlight) Windows Phone 库。 通常 Windows Phone Store Application 你应该使用 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;
    }