Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows phone 7.1 can I change font size on a shell tile?
    primarykey
    data
    text
    <p>I'm trying to display a tweet on the backside of a live tile, when I set it as BackContent it's way too big.... Is there any way to lower the font size?</p> <p>EDIT: </p> <p>Claus, Now i'm having trouble getting the tile to display and I can't get any info on why it's not working due to the nature of your ImageOpened call, I can't step through it with the debugger....</p> <p>In my TileGenerator class, this works:</p> <pre><code> public static void GenerateTestTile(string strTweet, string strScreenName, string tileTitle) { // Define the tile's address. This is where you navigate, when the tile is clicked. var address = "/MainPage.xaml?TileID=6"; // Check if a tile with the same address already exists //var tile = ShellTile.ActiveTiles.FirstOrDefault(x =&gt; x.NavigationUri.ToString() == address); var tile = ShellTile.ActiveTiles.First(); // Define our tile data. var tileData = new StandardTileData { BackTitle = strScreenName, BackContent = strTweet }; // If the file already exists, update it. if (tile != null) { tile.Update(tileData); } else { // Otherwise, create a new tile. ShellTile.Create(new Uri(address, UriKind.Relative), tileData); } } </code></pre> <p>But this doesn't (exact method taken from your example), it doesn't do anything to the tile at all...</p> <pre><code> public static void GenerateExampleTile(string timeOfDay, string temperature, Uri cloudImagePath, string tileTitle) { // Setup the font style for our tile. var fontFamily = new FontFamily("Segoe WP"); var fontForeground = new SolidColorBrush(Colors.White); var tileSize = new Size(173, 173); // Create a background rectagle for a custom colour background. var backgroundRectangle = new Rectangle(); backgroundRectangle.Width = tileSize.Width; backgroundRectangle.Height = tileSize.Height; backgroundRectangle.Fill = new SolidColorBrush(Colors.Blue); // Load our 'cloud' image. var source = new BitmapImage(cloudImagePath); source.CreateOptions = BitmapCreateOptions.None; source.ImageOpened += (sender, e) =&gt; // This is important. The image can't be rendered before it's loaded. { // Create our image as a control, so it can be rendered to the WriteableBitmap. var cloudImage = new Image(); cloudImage.Source = source; cloudImage.Width = 100; cloudImage.Height = 64; // TextBlock for the time of the day. TextBlock timeOfDayTextBlock = new TextBlock(); timeOfDayTextBlock.Text = timeOfDay; timeOfDayTextBlock.FontSize = 20; timeOfDayTextBlock.Foreground = fontForeground; timeOfDayTextBlock.FontFamily = fontFamily; // Temperature TextBlock. TextBlock temperatureTextBlock = new TextBlock(); temperatureTextBlock.Text = temperature + '°'; temperatureTextBlock.FontSize = 30; temperatureTextBlock.Foreground = fontForeground; temperatureTextBlock.FontFamily = fontFamily; // Define the filename for our tile. Take note that a tile image *must* be saved in /Shared/ShellContent // or otherwise it won't display. var tileImage = string.Format("/Shared/ShellContent/{0}.jpg", timeOfDay); // Define the path to the isolatedstorage, so we can load our generated tile from there. var isoStoreTileImage = string.Format("isostore:{0}", tileImage); // Open the ISF store, using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { // Create our bitmap, in our selected dimension. var bitmap = new WriteableBitmap((int)tileSize.Width, (int)tileSize.Height); // Render our background. Remember the renders are in the same order as XAML, // so whatever is rendered first, is rendered behind the next element. bitmap.Render(backgroundRectangle, new TranslateTransform()); // Render our cloud image bitmap.Render(cloudImage, new TranslateTransform() { X = 8, // Left margin offset. Y = 54 // Top margin offset. }); // Render the temperature text. bitmap.Render(temperatureTextBlock, new TranslateTransform() { X = 124, Y = 63 }); // Render the time of the day text. bitmap.Render(timeOfDayTextBlock, new TranslateTransform() { X = 12, Y = 6 }); // Create a stream to store our file in. var stream = store.CreateFile(tileImage); // Invalidate the bitmap to make it actually render. bitmap.Invalidate(); // Save it to our stream. bitmap.SaveJpeg(stream, 173, 173, 0, 100); // Close the stream, and by that saving the file to the ISF. stream.Close(); } // Define the tile's address. This is where you navigate, when the tile is clicked. var address = "/MainPage.xaml?TileID=" + timeOfDay; // Check if a tile with the same address already exists var tile = ShellTile.ActiveTiles.FirstOrDefault(x =&gt; x.NavigationUri.ToString() == address); // Define our tile data. var tileData = new StandardTileData { BackgroundImage = new Uri(isoStoreTileImage, UriKind.Absolute), Title = tileTitle, }; // If the file already exists, update it. if (tile != null) { tile.Update(tileData); } else { // Otherwise, create a new tile. ShellTile.Create(new Uri(address, UriKind.Relative), tileData); } }; } </code></pre> <p>Both methods are being called in this way....</p> <p>public class ScheduledAgent : ScheduledTaskAgent {</p> <pre><code> ... /// &lt;summary&gt; /// Agent that runs a scheduled task /// &lt;/summary&gt; /// &lt;param name="task"&gt; /// The invoked task /// &lt;/param&gt; /// &lt;remarks&gt; /// This method is called when a periodic or resource intensive task is invoked /// &lt;/remarks&gt; protected override void OnInvoke(ScheduledTask task) { LoadWatchList(); } //WATCH LIST private void LoadWatchList() { if (HasConnectivity) { GetWatchListTweetsFromTwitter(CurrentWatchListID); } } public void GetWatchListTweetsFromTwitter(int list_id) { WebClient wcWatchListTimeline = new WebClient(); wcWatchListTimeline.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wcWatchListTimeline_DownloadStringCompleted); wcWatchListTimeline.DownloadStringAsync(new System.Uri("https://api.twitter.com/1/lists/statuses.xml?per_page=1&amp;list_id=" + list_id)); } void wcWatchListTimeline_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { String strTweet = "content"; String strScreenName = "title"; if (e.Error != null) { strScreenName = "error"; strTweet = e.Error.Message; } else { XElement tweet = XElement.Parse(e.Result); Tweet thisTweet = GetTweet(tweet); if (thisTweet != null) { strTweet = thisTweet.text; strScreenName = thisTweet.screen_name; } } // TAKEN FROM EXAMPLE FOR TESTING - NOT WORKING string timeOfday = "morning"; string temperature = "99"; string location = "San Antonio"; Uri cloudImagePath = new Uri("Images/tweetEmpty.png", UriKind.Relative); Deployment.Current.Dispatcher.BeginInvoke(() =&gt; TileGenerator.GenerateExampleTile(timeOfday, temperature, cloudImagePath, "mainTile")); //WORKING //Deployment.Current.Dispatcher.BeginInvoke(() =&gt; TileGenerator.GenerateTile(strTweet, strScreenName, "mainTile")); NotifyComplete(); } protected Tweet GetTweet(XElement Xdata) { List&lt;Tweet&gt; listTweets = (from tweet in Xdata.Descendants("status") select new Tweet { screen_name = tweet.Element("user").Element("screen_name").Value, text = tweet.Element("text").Value }).ToList&lt;Tweet&gt;(); if (listTweets.Count &gt; 0) { return listTweets[0]; } else { return null; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload