WP7.1 backward compatibility

房东的猫 提交于 2019-12-13 09:27:28

问题


I have installed mango SDK in my machine and I want to create an application which runs on both Windows Phone OS 7.0 and Windows Phone OS 7.5 devices. Also I need to implement many of the mango features in the same application. Is it possible ? if yes please tell me how to do the version checking, because based on the version we need to implement the mango features.


回答1:


You'll have to maintain two different versions. You can't compile one XAP that supports both versions at the same time.

The Mango APIs are only available when compiling with the 7.1 SDK. And as such, you can't do in-line checking in the code.

But it's rather pointless, as there's almost no users left that haven't upgraded to Mango, and all new phones ship with Mango.




回答2:


Now days all the Windows phone are shipping with the Wp7.5 mango version also Older devices are getting mango updates, so it looks pointless in targeting only few WP7.0 running phones.

But if you dont need to anything SDK related api access then you can do this bifurcation.

However You can find the solution to the finding the OS version is in [my answer of same kind of question here.]1




回答3:


You can do this using the Type class and reflection, although the process will not be easy. Create a Windows Phone 7.0 application, and then create a MangoExtensions class which implements the mango specific features:

http://www.sharpgis.net/post/2011/08/21/Windows-Phone-Adding-Mango-features-to-a-70-WinPhone-App.aspx

bool IsMangoDevice = (Environment.OSVersion.Version >= new Version(7, 1));

if (IsMangoDevice)
{
  Type t = Type.GetType("Microsoft.Phone.Shell.StandardTileData, Microsoft.Phone");

  //get the constructor for the StandardTileData and create a new instance of it
  var newTileData = t.GetConstructor(new Type[] { }).Invoke(null);
  //Get the setter method for the title property
  var setMethod = newTileData.GetType().GetProperty("Title").GetSetMethod();
  //Set the tile title
  setMethod.Invoke(newTileData, new object[] { "This is my new tile" });
  //Get the create method for the shell tiles
  Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
  var createMethod = shellTileType.GetMethod("Create");
  //Create the tile, with the uri and tile data
  Uri uri = new new Uri("/MainPage.xaml?Test=This_Came_From_A_Secondary_Tile", UriKind.Relative)
  createMethod.Invoke(null, new object[] {  uri, newTileData});
}


来源:https://stackoverflow.com/questions/8723119/wp7-1-backward-compatibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!