gpt4 book ai didi

windows-phone-7 - 将 Windows Phone 8 Tile 功能添加到 Windows Phone OS 7.1 应用程序

转载 作者:行者123 更新时间:2023-12-02 00:15:01 29 4
gpt4 key购买 nike

我正在尝试使用 documentation from MSDN 在我现有的 Windows Phone OS 7.1 应用程序中支持新的 Windows Phone 磁贴功能。 .但是,我似乎无法通过反射创建 IconicTile,因为它一直给我 NullReferenceExceptions 和 AmbiguousMatchExceptions。这是我正在使用的代码:

public static void CreateIconicTile(Uri tileId, string title, int count, string wideContent1, string wideContent2, string wideContent3, Uri smallIconImage, Uri iconImage, Color backgroundColor)
{
// Get the new IconicTileData type.
Type iconicTileDataType = Type.GetType("Microsoft.Phone.Shell.IconicTileData, Microsoft.Phone");

// Get the ShellTile type so we can call the new version of "Update" that takes the new Tile templates.
Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");

// Get the constructor for the new IconicTileData class and assign it to our variable to hold the Tile properties.
StandardTileData CreateTileData = new StandardTileData();

// Set the properties.
SetProperty(CreateTileData, "Count", count);
SetProperty(CreateTileData, "WideContent1", wideContent1);
SetProperty(CreateTileData, "WideContent2", wideContent2);
SetProperty(CreateTileData, "WideContent3", wideContent3);
SetProperty(CreateTileData, "SmallIconImage", smallIconImage);
SetProperty(CreateTileData, "IconImage", iconImage);
SetProperty(CreateTileData, "BackgroundColor", backgroundColor);

// Invoke the new version of ShellTile.Create.
shellTileType.GetMethod("Create").Invoke(null, new Object[] { tileId, CreateTileData });
}

我还尝试使用 Windows Phone OS 7.1 方式 (ShellTile.Create(...)) 创建磁贴,然后通过反射调用 UpdateIconicTile 方法,如所述在 MSDN 文档中。但这也不起作用。

如有任何帮助,我们将不胜感激。谢谢!

编辑:澄清一下,我正在检查平台版本以确保此代码仅在 Windows Phone 8 设备上运行,并且我已将必要的代码添加到我的 list 中。

已解决:感谢 Martin Suchan 在下面给出的答案,我能够解决这个问题。问题是我对 Invoke(...) 的调用缺少一些属性。这是我用来实际创建磁贴的新行:

shellTileType.GetMethod("Create", new Type[] { typeof(Uri), typeof(ShellTileData), typeof(bool) }).Invoke(null, new Object[] { tileId, CreateTileData, true });

最佳答案

您是否尝试过 Mangopollo 库,它包含用于在 WP8 上运行时在 WP7.1 应用程序中创建新图 block 的工作包装器?
http://mangopollo.codeplex.com/

关于windows-phone-7 - 将 Windows Phone 8 Tile 功能添加到 Windows Phone OS 7.1 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13636069/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com