我正在创建Windows Runtime App
,但我似乎无法访问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");
}
}
}
答案 0 :(得分:3)
在Windows运行时应用程序中,MessageBox可以通过以下代码显示:
new MessageDialog("Your Message Content").ShowAsync();