I have a Windows Phone 8 supporting Live Tiles (the default medium and small). I update the Live Tile using a fairly standard code
var tile = ShellTile.ActiveTiles.First();
if (tile == null) return;
var data = new StandardTileData {Title = "some title"};
data.BackgroundImage = new Uri("/Background.png", UriKind.Relative);
data.Count = count;
tile.Update(data);
I want to add support for the Large tile but I want to to be different. I do not want to use the count and I want to render some custom text to the images:
var data = new StandardTileData {Title = "some title"};
data.BackgroundImage = new Uri("path to a custom rendered image", UriKind.Relative);
data.Count = 0;
My question is, how do I determine if my Live tile is Medium (small) or Large make the appropriate update? Or how do I set the tile update to be entirely different for Medium (small) and Large tile?
StandardTileData is the WP7 specific format for tile data. It's WP8 equivalent is
FlipTileData which includes separate properties for the different tile sizes:
FlipTileData TileData = new FlipTileData()
{
Title = "[title]",
BackTitle = "[back of Tile title]",
BackContent = "[back of medium Tile size content]",
WideBackContent = "[back of wide Tile size content]",
Count = [count],
SmallBackgroundImage = [small Tile size URI],
BackgroundImage = [front of medium Tile size URI],
BackBackgroundImage = [back of medium Tile size URI],
WideBackgroundImage = [front of wide Tile size URI],
WideBackBackgroundImage = [back of wide Tile size URI],
};
See also the WP8 specific docs for tiles. http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202948(v=vs.105).aspx
Related
First of all I'm very new to Windows Phone dev so I might miss something obvious.
I have a ControlMap in my xaml, i'm trying to add marker at my current location. I've gone through many tutorials and I can't only find deprecated ways (tons of using not working) to do it and while it seems simple at first view, I simply can't make it work.
The map in the xaml :
<Maps:MapControl x:Name="LocateMap" Height="221" Margin="0,0,-0.167,0"/>
What should I do in the .cs to add this marker ? And where ?
The intent is to store it later, and then print when the app launch all the olds markers + the actual location marker.
If you want to set a pin on a specific location (latitude, longitude), do the following steps.
//setting the Map center
LocateMap.Center = CurrentLocation = new System.Device.Location.GeoCoordinate(lat, lon);
// Create a small circle to mark the current location.
Ellipse myCircle = new Ellipse();
myCircle.Fill = App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
// Create a MapOverlay to contain the circle.
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat,
lon);
// Create a MapLayer to contain the MapOverlay.
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
//adding map layer to the map
LocateMap.Layers.Add(myLocationLayer);
How do I make my live tile for Windows Phone 8.1 Flip?
I have this piece of code, but have no clue where to add it. Or if there is anything else I need to implement.
FlipTileData TileData = new FlipTileData()
{
Title = "[title]",
BackTitle = "[back of Tile title]",
BackContent = "[back of medium Tile size content]",
WideBackContent = "[back of wide Tile size content]",
Count = 2,
SmallBackgroundImage = new Uri("/Assets/Tiles/ApplicationIcon.png", UriKind.Relative),
BackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
BackBackgroundImage = new Uri("/Assets/Tiles/CycleImage1Medi.png", UriKind.Relative),
WideBackgroundImage = new Uri("/Assets/Tiles/CycleTileLarge.png", UriKind.Relative),
WideBackBackgroundImage = new Uri("/Assets/Tiles/CycleImage1Wide.png", UriKind.Relative),
};
What am I suppose to do from here? Thanks for the help!
I'm not sure whether this template of FlipTileData would apply for for WP 8.1.
This thread talks about the live tiles for WP 8.1.
http://blogs.msdn.com/b/thunbrynt/archive/2014/04/10/windows-phone-8-1-for-developers-live-tiles.aspx
This one could be a reference too.
Hope it helps!
I need to update data on several secondary tiles in a windows phone 8 application. I am using a BackGround Agent to update the tiles.
IconicTileData tileData = new IconicTileData
{
IconImage = new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute),
Title = "My Tile title",
Count = new Random().Next(1, 10),
};
ShellTile mainTile = ShellTile.ActiveTiles.FirstOrDefault();
if (mainTile != null)
{
mainTile.Update(tileData);
}
// If debugging is enabled, launch the agent again in one minute.
#if DEBUG_AGENT
ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
#endif
Here it is to update the mainTile data. But how can I find how many secondary tiles are pinned and how to update them individually?
Frok the MSDN documentation for ShellTile.ActiveTiles: This list includes an Application Tile, which cannot be deleted, and all of its Secondary Tiles. The Application Tile is always the first in the collection.
So:
foreach (var tile in ShellTile.ActiveTiles)
{
//update the tile
}
As you know each tile has some Navigation URI.You can search for unique word in the query string of Navigation URI.
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("unique key/value in querystring"));
In this way you can identify all secondary tiles by iterating through them and checking the Navigation URI.
I have an application with pinned secondary live tiles, they are showing days on the back of the tile and I would like to reduce the number of days each day. Now the problem is, that I don't want to change the other properties of the tile (so Title, Images, etc), only the content (a string) on the back: FlipTileData.BackContent
So I don't want to create new FlipTileData to pass that as a parameter for the Update method.
Second problem: How do I even know which tile is what I'm about to update?
I've tried this:
foreach (ShellTile tile in ShellTile.ActiveTiles) but tile has no attribute that gives me a help. Should I use NavigationUri to find out which tile is that?
Follow this example Working with Live Tiles in Windows Phone 7 and it should solve your problems.
Notice the x.NavigationUri.ToString().**Contains("Title=SecondaryTile")** on the code.
EDIT:
Combining a few lines of code from that website:
// modify Application Secondary Tile data
private void updateTile_Click(object sender, RoutedEventArgs e)
{
// get application specific tile - EXAMPLE
ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Title=SecondaryTileEXAMPLE_TITLE"));
if (null != tile)
{
// create a new data for tile
StandardTileData data = new StandardTileData();
// tile foreground data
data.Title = "Title text here";
data.BackgroundImage = new Uri("/Images/Blue.jpg", UriKind.Relative);
data.Count = random.Next(99);
// to make tile flip add data to background also
data.BackTitle = "Secret text here";
data.BackBackgroundImage = new Uri("/Images/Green.jpg", UriKind.Relative);
data.BackContent = "Back Content Text here...";
// update tile
tile.Update(data);
}
}
I'm having a strange problem. I generate my live tile images in the BackgroundTask based on weather information. Sometimes I see that the image is being generated, but the tile only shows its background color and not the image (for instance, the tile is green or red and it shows only the title).
When I then remove the live tile, and re-pin it to the start screen the image does show. Or, on Windows Phone 8, when I change the size (Small => Medium => Wide) the live tile shows the image just fine. It sometimes happens on the Background image, and on the BackBackground image. Even re-starting the phone or open the app seems to help (but not 100% on this).
This seems like a small bug in the Windows Phone OS. What could be the problem?
This is my code:
using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/Image.jpg", System.IO.FileMode.Create, ISF))
{
writeableTileFinal.SaveJpeg(imageStream, writeableTileFinal.PixelWidth, writeableTileFinal.PixelHeight, 0, 100);
}
}
ShellTile appTile = ShellTile.ActiveTiles.First();
if (appTile != null)
{
StandardTileData tileData = new StandardTileData()
{
Title = "Title",
BackContent = string.Empty,
BackTitle = string.Empty,
BackgroundImage = new Uri("isostore:/Shared/ShellContent/Image.jpg", UriKind.Absolute),
};
appTile.Update(tileData);
}
UPDATE:
I seem to have fixed it (it didn't happen afterwards) by using Thread.Sleep just before the tile updates itself.:
Thread.Sleep(2000);
appTile.Update(tileData);
It works, but does someone knows what could have been the problem?