Font style in TextBlock from Isolated Storage in Windows Phone

void FileStreamingCompleted(object sender, FileStreamingCompletedEventArgs e)
{
   IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
   FontSource objFontSource;
   using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream
("Font.ttf",System.IO.FileMode.Create, file))
   {
      fs.Write(e.Result.byteArray, 0, e.Result.byteArray.Length);
   }
   using (IsolatedStorageFileStream fileStream = file.OpenFile("Font.ttf",
 FileMode.Open, FileAccess.Read))
   {
      StreamReader reader = new StreamReader(fileStream);
      objFontSource = new FontSource(reader.BaseStream);
      MyTextBlock.FontFamily = new FontFamily("Font Name");
      MyTextBlock.FontSource = objFontSource;
   }
   MyTextBlock.Text = "Changed Font";
}

Comments

Popular posts from this blog

Designing a hybrid mobile application with Ionic Framework

The last candle

A Rudderless Dance