如何根据用户在 Windows Phone 8 中选择的语言更改消息框按钮内容



我正在开发Windows Phone 8应用程序,这个应用程序应该可以用英语和阿拉伯语两种语言工作。

在某些屏幕中,我显示带有一些消息和按钮的消息框(确定,取消)。当应用程序为英文时,按钮内容(确定和取消)以英文显示。没事。

但是,当应用程序以阿拉伯语运行时,按钮内容不会以英语显示 Arabic.It 仅以英语显示

我应该如何根据语言更改按钮内容。

谢谢

您应该使用 Windows Phone 工具包 CustomMessageBox 控件。它可以很容易地本地化:

 CustomMessageBox messageBox = new CustomMessageBox()
    {                
        Caption = "Do you like this sample?",
        Message = "There are tons of things you can do using custom message boxes. To learn more, be sure to check out the source code at Codeplex.",
        LeftButtonContent = "yes",
        RightButtonContent = "no",
        IsFullScreen = (bool)FullScreenCheckBox.IsChecked
    };

在Windows Phone 8中,您可以访问Microsoft.Xna.Framework.GameServices它具有更通用的消息框,您可以使用而无需下载单独的库。

IAsyncResult result = Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
    AppResources.SmsConfirmText,
    "",
    new string[] { AppResources.OkText, AppResources.CancelText },
    0,
    Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None,
    null,
    null);
// Include following line if you want it to be synchronous
result.AsyncWaitHandle.WaitOne();
int? choice = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result);
if(choice.HasValue)
{
    if(choice.Value==0)
    {
        // User clicked on the first button: AppResources.OkText
    }
    else if(choice.Value==1)
    {
        // User clicked on the second button: AppResources.CancelText
    }
}

来源:http://developer.nokia.com/community/wiki/Advanced_MessageBox_for_Windows_Phone

最新更新