My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.
SILVERLIGHT CODE EXAMPLE created on Wednesday, June 30, 2010 permalink
How to create a TextBlock that has various font formatting in code behind
When you create a TextBlock, you can assign it a text and then assign formatting only to the whole text, e.g. the whole TextBlock can be one color. If you want different parts of the TextBlock.Text to be various colors and have various formatting (e.g. italic/bold), you can create as many Run elements as you need and add them to the TextBlock with Inlines collection.
XAML:
<UserControl x:Class="TestRun2343.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <StackPanel HorizontalAlignment="Left" Margin="10">
        <ContentControl Content="{Binding MainContent}"/>
    </StackPanel>
</UserControl>

Code Behind:
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace TestRun2343
{
    public partial class MainPage : UserControl, INotifyPropertyChanged
    {
        #region ViewModelProperty: MainContent .
        private object _mainContent;
        public object MainContent
        {
            get
            {
                return _mainContent;
            }

            set
            {
                _mainContent = value;
                OnPropertyChanged("MainContent");
            }
        }
        #endregion .

        public MainPage()
            : base()
        {
            InitializeComponent();
            DataContext = this;

            TextBlock tb = new TextBlock();
            tb.FontSize = 14;
            tb.FontFamily = new FontFamily("Courier");

            Run runLabel = new Run();
            runLabel.Foreground = new SolidColorBrush(Colors.Brown);
            runLabel.Text = "Test 1: ";

            Run runContent = new Run();
            runContent.Foreground = new SolidColorBrush(Colors.Black);
            runContent.FontStyle = FontStyles.Italic;
            runContent.Text = "This is the first test.";

            tb.Inlines.Add(runLabel);
            tb.Inlines.Add(runContent);

            MainContent = tb;
        }

        #region INotifiedProperty Block .
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion .
    }
}
need markup?