C# 将侦听器添加到Windows Phone中的MessageBox确定按钮

C# 将侦听器添加到Windows Phone中的MessageBox确定按钮,c#,.net,windows-phone-8,messagebox,C#,.net,Windows Phone 8,Messagebox,我以这种方式使用了MessageBox: Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show("The alarm has been raised"); }); 用户点击“确定”后如何执行操作?在简单情况下,您可以使用MessageBoxResult(在Windows Phone下,仅限于按钮“确定/确定取消”): IAsyncResu

我以这种方式使用了
MessageBox

Deployment.Current.Dispatcher.BeginInvoke(() => {

                MessageBox.Show("The alarm has been raised");
            });

用户点击“确定”后如何执行操作?

在简单情况下,您可以使用
MessageBoxResult
(在Windows Phone下,仅限于按钮“确定/确定取消”):

        IAsyncResult result =Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
"Info",
"Alarm has been raised",
new string[] { "OK", "Call emergency" },
0,
Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None,
null,
null);

       result.AsyncWaitHandle.WaitOne();
        media.AutoPlay = true;
    }

但它几乎没有限制,您无法更改按钮内容。您使用的解决方案更具可配置性。您也可以使用其他解决方案:如果您有Telerik-。

在简单的情况下,您可以使用
MessageBoxResult
(在Windows Phone下,仅限于按钮“确定/确定取消”):


但它几乎没有限制,您无法更改按钮内容。您使用的解决方案更具可配置性。您也可以使用其他解决方案:如果您有Telerik-。

在简单的情况下,您可以使用
MessageBoxResult
(在Windows Phone下,仅限于按钮“确定/确定取消”):


但它几乎没有限制,您无法更改按钮内容。您使用的解决方案更具可配置性。您也可以使用其他解决方案:如果您有Telerik-。

在简单的情况下,您可以使用
MessageBoxResult
(在Windows Phone下,仅限于按钮“确定/确定取消”):


但它几乎没有限制,您无法更改按钮内容。您使用的解决方案更具可配置性。您还可以使用其他解决方案:如果您有Telerik-。

请在项目中添加Microsoft.Xna.Framework.GamerServices的参考

Deployment.Current.Dispatcher.BeginInvoke(() => {
            List<string> messageboxitm = new List<string>();
            messageboxitm.Add("Yes");
            messageboxitm.Add("No");
            IAsyncResult result = Guide.BeginShowMessageBox("Message", "The alarm has been raised", messageboxitm, 0, MessageBoxIcon.Alert, new AsyncCallback(OnMessageBoxClosed), null);

});
 private void OnMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);
            switch (buttonIndex)
            {
                case 0:
                   //Do your work
                    break;               
                default:
                    break;
            }
        }
Deployment.Current.Dispatcher.BeginInvoke(()=>{
List messageboxitm=新列表();
messageboxitm.Add(“是”);
messageboxitm.添加(“否”);
IAsyncResult result=Guide.BeginShowMessageBox(“消息”,“警报已发出”,messageboxitm,0,MessageBoxIcon.Alert,新建异步回调(OnMessageBoxClosed),null);
});
MessageBoxClosed上的私有无效(IAsyncResult ar)
{
int?buttonIndex=Guide.EndShowMessageBox(ar);
开关(按钮索引)
{
案例0:
//做你的工作
打破
违约:
打破
}
}

在项目中添加对Microsoft.Xna.Framework.GamerServices的引用

Deployment.Current.Dispatcher.BeginInvoke(() => {
            List<string> messageboxitm = new List<string>();
            messageboxitm.Add("Yes");
            messageboxitm.Add("No");
            IAsyncResult result = Guide.BeginShowMessageBox("Message", "The alarm has been raised", messageboxitm, 0, MessageBoxIcon.Alert, new AsyncCallback(OnMessageBoxClosed), null);

});
 private void OnMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);
            switch (buttonIndex)
            {
                case 0:
                   //Do your work
                    break;               
                default:
                    break;
            }
        }
Deployment.Current.Dispatcher.BeginInvoke(()=>{
List messageboxitm=新列表();
messageboxitm.Add(“是”);
messageboxitm.添加(“否”);
IAsyncResult result=Guide.BeginShowMessageBox(“消息”,“警报已发出”,messageboxitm,0,MessageBoxIcon.Alert,新建异步回调(OnMessageBoxClosed),null);
});
MessageBoxClosed上的私有无效(IAsyncResult ar)
{
int?buttonIndex=Guide.EndShowMessageBox(ar);
开关(按钮索引)
{
案例0:
//做你的工作
打破
违约:
打破
}
}

在项目中添加对Microsoft.Xna.Framework.GamerServices的引用

Deployment.Current.Dispatcher.BeginInvoke(() => {
            List<string> messageboxitm = new List<string>();
            messageboxitm.Add("Yes");
            messageboxitm.Add("No");
            IAsyncResult result = Guide.BeginShowMessageBox("Message", "The alarm has been raised", messageboxitm, 0, MessageBoxIcon.Alert, new AsyncCallback(OnMessageBoxClosed), null);

});
 private void OnMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);
            switch (buttonIndex)
            {
                case 0:
                   //Do your work
                    break;               
                default:
                    break;
            }
        }
Deployment.Current.Dispatcher.BeginInvoke(()=>{
List messageboxitm=新列表();
messageboxitm.Add(“是”);
messageboxitm.添加(“否”);
IAsyncResult result=Guide.BeginShowMessageBox(“消息”,“警报已发出”,messageboxitm,0,MessageBoxIcon.Alert,新建异步回调(OnMessageBoxClosed),null);
});
MessageBoxClosed上的私有无效(IAsyncResult ar)
{
int?buttonIndex=Guide.EndShowMessageBox(ar);
开关(按钮索引)
{
案例0:
//做你的工作
打破
违约:
打破
}
}

在项目中添加对Microsoft.Xna.Framework.GamerServices的引用

Deployment.Current.Dispatcher.BeginInvoke(() => {
            List<string> messageboxitm = new List<string>();
            messageboxitm.Add("Yes");
            messageboxitm.Add("No");
            IAsyncResult result = Guide.BeginShowMessageBox("Message", "The alarm has been raised", messageboxitm, 0, MessageBoxIcon.Alert, new AsyncCallback(OnMessageBoxClosed), null);

});
 private void OnMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);
            switch (buttonIndex)
            {
                case 0:
                   //Do your work
                    break;               
                default:
                    break;
            }
        }
Deployment.Current.Dispatcher.BeginInvoke(()=>{
List messageboxitm=新列表();
messageboxitm.Add(“是”);
messageboxitm.添加(“否”);
IAsyncResult result=Guide.BeginShowMessageBox(“消息”,“警报已发出”,messageboxitm,0,MessageBoxIcon.Alert,新建异步回调(OnMessageBoxClosed),null);
});
MessageBoxClosed上的私有无效(IAsyncResult ar)
{
int?buttonIndex=Guide.EndShowMessageBox(ar);
开关(按钮索引)
{
案例0:
//做你的工作
打破
违约:
打破
}
}

MessageBox.Show方法返回一个
MessageBoxResult
变量,该变量指示所采取的操作(确定、取消、无、是或否)。请参阅。
MessageBox.Show
方法返回一个
MessageBoxResult
变量,该变量指示所采取的操作(确定、取消、无、是或否)。请参阅。
MessageBox.Show
方法返回一个
MessageBoxResult
变量,该变量指示所采取的操作(确定、取消、无、是或否)。请参阅。
MessageBox.Show
方法返回一个
MessageBoxResult
变量,该变量指示所采取的操作(确定、取消、无、是或否)。请参阅。被接受为最优雅的解决方案。被接受为最优雅的解决方案。被接受为最优雅的解决方案。被接受为最优雅的解决方案。