ShellTile不会更新Windows Phone上的数据

时间:2014-04-14 14:51:15

标签: windows-phone-7 windows-phone

我想在我的应用程序运行时安排多个平铺通知,这样当我的应用程序处于后台时,我的计划平铺通知会逐个使用相应的发生时间。 但不知何故,当我安排多个(3)通知时,只会出现最后一个通知。

String message = "";
String key = "FamilyFarm" + count;
if (String.IsNullOrEmpty(duration) || String.IsNullOrEmpty(name)) 
    return;
IsolatedStorageSettings setting = IsolatedStorageSettings.ApplicationSettings;
if (setting.Contains(key))
{
    setting.Remove(key);
}
setting.Add(key, name);
count++;

ShellTileSchedule SampleTileSchedule = new ShellTileSchedule();
bool TileScheduleRunning = false;

// Update will happen one time.
SampleTileSchedule.Recurrence = UpdateRecurrence.Onetime;

// Start the update schedule now. 
SampleTileSchedule.StartTime = DateTime.Now;

SampleTileSchedule.RemoteImageUri = new Uri(@"http://www.weather.gov/forecasts/graphical/images/conus/MaxT1_conus.png");
SampleTileSchedule.Start();
TileScheduleRunning = true;

ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x =>    x.NavigationUri.ToString().Contains("flip".ToString()));

if (oTile != null && oTile.NavigationUri.ToString().Contains("flip"))
{
    FlipTileData oFliptile = new FlipTileData();
    oFliptile.Title = name;
    oFliptile.Count = 11;
    oFliptile.BackTitle = key;

    oFliptile.BackContent = name;
    oFliptile.WideBackContent = name;

    oFliptile.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative);
    oFliptile.BackgroundImage = new Uri("Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative);
    oFliptile.WideBackgroundImage = new Uri("Assets/Tiles/Flip/FlipCycleTileLarge.png", UriKind.Relative);

    oFliptile.BackBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative);
    oFliptile.WideBackBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative);
    oTile.Update(oFliptile);
    // MessageBox.Show("Flip Tile Data successfully update.");
    //return true;
}
else
{
    // once it is created flip tile
    Uri tileUri = new Uri("/MainPage.xaml?tile=flip", UriKind.Relative);
    ShellTileData tileData =  new FlipTileData()
    {
        Title = "Hello FamilyFarm",
        BackTitle = key,
        BackContent = name,
        WideBackContent = name,
        Count = 8,
        SmallBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
        BackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
        WideBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
    };
    ShellTile.Create(tileUri, tileData, true);
}

1 个答案:

答案 0 :(得分:0)

如果您想查看平铺周期,则应使用

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207036(v=vs.105).aspx

Creating CycleTile with remote images

否则,如果您希望查看更新,则应在更新之间加上Thread.SleepTask.Wait,以便能够看到它们。

如果你想在WP7.8中进行一些骑行,你可以使用MangoPollo。