WPF C# Tutorial

  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="WpfApplication1.Window1"
  Title="Using a Path Geometry to Highlight Text"
  Background="PowderBlue">
  
      Display Text
    
      
      
        
          
            
              
              
            

          
        

        
          
        

        
          
            
            
              
                                  x:Name="matrixAnimation"
                  Duration="0:00:40"
                  RepeatBehavior="Forever"
                  Storyboard.TargetProperty="RenderTransform.Matrix" />
              
            

            

          
        

      
    
  


//File:Window.xaml.cs
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
namespace WpfApplication1
{
    public partial class Window1 : Window
    {     
        public Window1()
        {
            InitializeComponent();
        }
        public void OnDisplayTextClick(object sender, EventArgs e)
        {
            FormattedText formattedText = new FormattedText(
                "asdf",
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Verdana"),
                96,
                Brushes.Black);
            formattedText.SetFontWeight(FontWeights.Bold);
            Geometry geometry = formattedText.BuildGeometry(new Point(0, 0));
            PathGeometry pathGeometry = geometry.GetFlattenedPathGeometry();
            path.Data = pathGeometry;
            matrixAnimation.PathGeometry = pathGeometry;
        }
    }
}