C# 无法访问Windows Phone中的MessageBox类
我正在创建一个C# 无法访问Windows Phone中的MessageBox类,c#,windows-phone-8,windows-8,C#,Windows Phone 8,Windows 8,我正在创建一个Windows运行时应用程序,似乎我没有任何访问MessageBox类的权限。文档说明它位于System.Windows命名空间中,因此我添加了它,但仍然无法访问MessageBox类 using System.Windows; public sealed partial class BillPage : Page { private Edge myEdge; public BillPage() { this.InitializeCompo
Windows运行时应用程序
,似乎我没有任何访问MessageBox
类的权限。文档说明它位于System.Windows
命名空间中,因此我添加了它,但仍然无法访问MessageBox
类
using System.Windows;
public sealed partial class BillPage : Page
{
private Edge myEdge;
public BillPage()
{
this.InitializeComponent();
MessageBox.Show("Test", "Test");
}
}
知道怎么回事吗?我只是个白痴还是什么?
文件:
完整代码:
using EdgeApp.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Windows;
// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
namespace EdgeApp
{
public sealed partial class BillPage : Page
{
private NavigationHelper navigationHelper;
private ObservableDictionary defaultViewModel = new ObservableDictionary();
private Edge myEdge;
public BillPage()
{
this.InitializeComponent();
myEdge = new Edge();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
}
public NavigationHelper NavigationHelper
{
get { return this.navigationHelper; }
}
public ObservableDictionary DefaultViewModel
{
get { return this.defaultViewModel; }
}
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
}
private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
{
}
#region NavigationHelper registration
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedFrom(e);
}
#endregion
private void MessageBoxTest(object sender, RoutedEventArgs e)
{
MessageBox.Show("text");
}
}
}
在Windows Runtime App中,MessageBox可以通过以下代码显示:
new MessageDialog("Your Message Content").ShowAsync();
您所说的“无权访问MessageBox类”到底是什么意思?编译时错误或运行时错误或它不工作或…?名称“MessageBox”在当前上下文中不存在。我现在快疯了。这是有史以来最基本的事情。请尝试添加“使用System.Windows.Forms;”无法在Windows应用商店应用程序中使用Forms messagebox。我试图手动引用DLL,当我试图弹出它时,它崩溃了哈哈。我的上帝,你是一个救世主。。。要是他们能更新他们的文档就好了。非常感谢你,克里斯!知道为什么其他文档显示您可以使用MessageBox类吗?不客气。也许他们的文档还没有完全更新。甚至谷歌搜索也只告诉你使用MessageBox。。。。是的,MessageBox可以在Windows Phone 8中使用。但无法在Windows Phone 8.1(运行时)中运行