I believe that I will be with XNA for the next spare time. Originally wanted to develop the depth of 3D development, but encountered a practical problem, is how to display the XNA under the MessageBox and software Input Panel. Just write it out first, so that you don't get mad when you meet the problem.
According to one of the few public document descriptions, XNA and Silverlight for Windows phone should be based on the CLR of the same. NET Compact framework. However, XNA does not provide any user controls, MessageBox, and soft keyboards, nor does it directly invoke the class library of Silverlight for Windows Phone. This is bound to create a lot of man-made obstacles for XNA. But calling MessageBox and software Input panel's back door, Xna still left us, this is the Guide class under the Microsoft.Xna.Framework.GamerServices namespace, the class description is as follows:
Http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamerservices.guide.aspx
This class can call not only MessageBox and soft keyboards, but also forms such as marketplace, XBox live, and so on. However, it is worth noting that the Guide class provides methods that are asynchronous, not synchronous, and it is understandable that the game is handled in a time-driven manner, so any operation should not block the main thread of the game.
Guide class calls the description of the MessageBox and the soft keyboard here:
Http://msdn.microsoft.com/en-us/library/ff827869.aspx
Http://msdn.microsoft.com/en-us/library/ff827868.aspx
However, there are some flaws in the MSDN documentation, which produces exception by the method provided above, so I'll give you a way to run the changes below. The operating environment is based on the VS + Windows Phone 7 SDK RTW Edition.
Call MessageBox
Create the project for XNA 4.0 in Windows Phone 7, and then we add a call to MessageBox in the Update method. Of course, please do not think that the MessageBox added to the update in the correct, this will cause MessageBox constantly pop up. I did it just to simplify the code.
protected override void Update (Gametime gametime)
{
allows the game to exit
if (gamepad.getstate
(Playerindex.one). Buttons.back = = buttonstate.pressed)
This. Exit ();
Todo:add Your update logic here
Mboptions. ADD ("OK");
Mboptions. Add
("Cancel");
if (! guide.isvisible)
Guide.beginshowmessagebox ("Test", "Hello, XNA",
mboptions, 0, Messageboxicon.alert, new AsyncCallback ( respcallback),
null);
Base. Update (gametime);
}