c#-无法访问Windows Phone中的MessageBox类
作者:互联网
我正在创建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");
}
}
知道发生了什么吗?我只是白痴还是什么?
文档:http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.messagebox(v=vs.105).aspx
完整代码:
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();
标签:windows-phone-8,windows-8,c 来源: https://codeday.me/bug/20191121/2053014.html