我正在创建Windows运行时应用程序,但似乎无权访问MessageBox类.文档指出它位于System.Windows命名空间中,因此我添加了它,但仍然无权访问MessageBox类.using System.Windows;public sealed partial class BillPage :...
我正在创建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();
沃梦达教程
本文标题为:c#-无法访问Windows Phone中的MessageBox类
基础教程推荐
猜你喜欢
- Unity3D网格功能生成球体网格模型 2023-01-11
- WPF实现绘制统计图(柱状图)的方法详解 2023-06-27
- C#获取所有进程的方法 2023-01-06
- 利用C#版OpenCV实现圆心求取实例代码 2023-01-22
- Unity Shader实现素描风格的渲染 2023-02-16
- 浅析C# 装箱和拆箱 2023-03-04
- C#异步编程async/await用法详解 2023-05-16
- LRU缓存替换策略及C#实现方法分享 2023-07-19
- C#实现密码验证与输错密码账户锁定 2023-05-31
- c# – 在Windows Phone 8中更改UriMapper后重定向页面 2023-09-20