WP7.1 backward compatibility

2019-09-24 08:53发布

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.

3条回答
一夜七次
2楼-- · 2019-09-24 09:12

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.

查看更多
做自己的国王
3楼-- · 2019-09-24 09:12

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

查看更多
Melony?
4楼-- · 2019-09-24 09:23

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});
}
查看更多
登录 后发表回答