【发布时间】:2012-10-04 07:10:22
【问题描述】:
在window phone 7.5 中。我想在消息框中使用 yes no 按钮。但是在消息框中没有选择 yes no 按钮。我如何使用 yes no 按钮或其他替代按钮来显示标题(确定 = 是,取消 = 否) 请帮帮我。
提前致谢。
【问题讨论】:
标签: c# windows-phone-7
在window phone 7.5 中。我想在消息框中使用 yes no 按钮。但是在消息框中没有选择 yes no 按钮。我如何使用 yes no 按钮或其他替代按钮来显示标题(确定 = 是,取消 = 否) 请帮帮我。
提前致谢。
【问题讨论】:
标签: c# windows-phone-7
您可以使用 Coding4Fun MessagePrompt 通过这种方式使用自定义按钮创建是/否消息:
MessagePrompt messagePrompt = new MessagePrompt();
messagePrompt.Message = "Some Message.";
Button yesButton = new Button() { Content = "Yes" };
yesButton .Click += new RoutedEventHandler(yesButton _Click);
Button noButton = new Button() { Content = "No" };
noButton .Click += new RoutedEventHandler(noButton _Click);
messagePrompt.ActionPopUpButtons.Add(noButton);
messagePrompt.ActionPopUpButtons.Add(yesButton );
messagePrompt.Show();
【讨论】:
另一个选择是使用 XNA 框架中的 Guide 类。有一个 BeginShowMessageBox 方法让您可以选择传入按钮所需的任何字符串。
【讨论】:
另一种选择是使用 Coding4fun 工具包中的MessagePrompt 并根据您的需要进行自定义
【讨论】:
是的,WP MessageBox 的问题在于它只支持 OK 和 OKCancel MessageBoxButton,这意味着您只能使用确定按钮或确定和取消按钮。不支持 YesNo 和 YesNoCancel 枚举值。
基本上你可以尝试在页面内容上显示一个半透明的空白层,然后在其上显示一个自定义消息框。 Here,您可以找到完整的样本。
另一种选择是使用自定义库,例如 Windows Phone Assets。
【讨论】: