Use a PathGeometry object to highlight displayed text.


   
  

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

  <StackPanel>
      <Button Margin="10" Grid.Column="2" Grid.Row="0" FontSize="16" Click="OnDisplayTextClick">Display Text</Button>
    <Canvas Margin="20" Height="150">
      <Path Canvas.Top="15" Canvas.Left="15" Stroke="SteelBlue" StrokeThickness="3" Fill="LightSteelBlue" Name="path" />
      <Ellipse Canvas.Top="0" Canvas.Left="0" Width="30" Height="30">
        <Ellipse.Fill>
          <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="Yellow" Offset="0.25" />
              <GradientStop Color="Transparent" Offset="1" />
            </RadialGradientBrush.GradientStops>
          </RadialGradientBrush>
        </Ellipse.Fill>

        <Ellipse.RenderTransform>
          <MatrixTransform />
        </Ellipse.RenderTransform>
        <Ellipse.Triggers>
          <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <EventTrigger.Actions>
            <BeginStoryboard>
              <Storyboard x:Name="storyboard">
                <MatrixAnimationUsingPath 
                  x:Name="matrixAnimation"
                  Duration="0:00:40"
                  RepeatBehavior="Forever"
                  Storyboard.TargetProperty="RenderTransform.Matrix" />
              </Storyboard>
            </BeginStoryboard>
            </EventTrigger.Actions>
          </EventTrigger>
        </Ellipse.Triggers>
      </Ellipse>
    </Canvas>
  </StackPanel>
</Window>

//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;
        }
    }
}

   
    
     


Converting text to geometry


   
  
<Window x:Class="GlyphExamples.GlyphClipping"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Glyph Clipping" Height="300" Width="300">
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="64">
      <Grid.LayoutTransform>
        <ScaleTransform ScaleX="4" ScaleY="4" />
      </Grid.LayoutTransform>
      <Button x:Name="button1" Content="Click" />
    </Grid>
</Window>

//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;

namespace GlyphExamples
{
    public partial class GlyphClipping : System.Windows.Window
    {
        public GlyphClipping()
        {
            InitializeComponent();
            FormattedText text = new FormattedText("CLIP!",
                Thread.CurrentThread.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface("Gill Sans Ultra Bold"),
                20,
                Brushes.Black);

            Geometry textGeometry = text.BuildGeometry(new Point(0, 0));
            button1.Clip = textGeometry;
        }
    }
}

   
    
     


Use PolyBezierSegment to Simulated Circle


   
      

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Path Canvas.Left="150" Canvas.Top="150" Stroke="Black">
        <Path.Data>
            <PathGeometry>
                <PathGeometry.Figures>
                    <PathFigure StartPoint="0 100">
                        <PolyBezierSegment 
                            Points="  55  100,  100   55,  100    0
                                     100  -55,   55 -100,    0 -100
                                     -55 -100, -100  -55, -100    0
                                    -100   55,  -55  100,    0  100" />
                    </PathFigure>
                </PathGeometry.Figures>
            </PathGeometry>
        </Path.Data>
    </Path>
</Canvas>

   
    
    
    
    
    
     


LineGeometry Demo


   
      

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Path Stroke="Blue" StrokeThickness="3">
        <Path.Data>
            <LineGeometry StartPoint="96 96"
                          EndPoint="192 192" />
        </Path.Data>
    </Path>

    <Path Stroke="Red" StrokeThickness="3">
        <Path.Data>
            <LineGeometry StartPoint="1 96"
                          EndPoint="96 192" />
        </Path.Data>
    </Path>

</Canvas>

   
    
    
    
    
    
     


Tiled Geometry

   
    
<Window  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SDKSample.SampleViewer"
    Title="  Examples" >

   <Canvas> 
        <Rectangle Height="200" Width="200" Stroke="Black" StrokeThickness="1"
          HorizontalAlignment="Left">
          <Rectangle.Fill>
            <DrawingBrush Viewbox="0,0,200,200" ViewboxUnits="Absolute" Viewport="0,0,0.5,0.5" TileMode="FlipXY">
              <DrawingBrush.Drawing>
                <GeometryDrawing Brush="#CCCCFF">
                  <GeometryDrawing.Pen>
                    <Pen Thickness="1" Brush="Black" />
                  </GeometryDrawing.Pen>
                  <GeometryDrawing.Geometry>
                    <GeometryGroup>
                      <RectangleGeometry Rect="50,50 195,80" />
                      <EllipseGeometry Center="100, 100" RadiusX="20" RadiusY="30"/>
                      <RectangleGeometry Rect="50,175 100,10" />
                      <PathGeometry>
                        <PathGeometry.Figures>
                          <PathFigureCollection>
                            <PathFigure IsClosed="true" StartPoint="50,50">
                              <PathFigure.Segments>
                                <PathSegmentCollection>
                                  <BezierSegment Point1="75,300" Point2="125,100" Point3="150,50"/>

                                  <BezierSegment Point1="5,700" Point2="225,100" Point3="150,50"/>
                                  <BezierSegment Point1="175,30" Point2="325,100" Point3="150,50"/>
                                  <BezierSegment Point1="125,300" Point2="75,200" Point3="50,50"/>
                                  <BezierSegment Point1="5,30"  Point2="175,400" Point3="150,50"/>
                                </PathSegmentCollection>
                              </PathFigure.Segments>
                            </PathFigure>
                          </PathFigureCollection>
                        </PathGeometry.Figures>
                      </PathGeometry>               
                    </GeometryGroup>                  
                  </GeometryDrawing.Geometry>
                </GeometryDrawing>
              </DrawingBrush.Drawing>
            </DrawingBrush>
          </Rectangle.Fill>
        </Rectangle> 
   </Canvas> 


</Window>

   
    
    
    
     


Geometry Used as a Clip

   
    
<Window  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SDKSample.SampleViewer"
    Title="  Examples" >

   <Canvas> 
       <Image Source="c:image.jpg" Width="200" Height="200" HorizontalAlignment="Left">
          <Image.Clip>
              <GeometryGroup>
                  <RectangleGeometry Rect="50,5 100,10" />
                  <RectangleGeometry Rect="5,5 95,180" />
                  <PathGeometry>
                    <PathGeometry.Figures>
                      <PathFigureCollection>
                        <PathFigure IsClosed="true" StartPoint="50,50">
                          <PathFigure.Segments>
                            <PathSegmentCollection>
                              <BezierSegment Point1="175,300" Point2="425,300" Point3="120,150"/>
                              <BezierSegment Point1="225,30" Point2="75,140" Point3="450,150"/>
                              <BezierSegment Point1="35,300" Point2="125,150" Point3="150,350"/>
                              <BezierSegment Point1="425,30" Point2="375,170" Point3="250,450"/>
                              <BezierSegment Point1="55,300" Point2="125,180" Point3="150,150"/>
                              <BezierSegment Point1="625,30" Point2="175,130" Point3="150,150"/>
                            </PathSegmentCollection>
                          </PathFigure.Segments>
                        </PathFigure>
                      </PathFigureCollection>
                    </PathGeometry.Figures>
                  </PathGeometry>               
              </GeometryGroup>            
          </Image.Clip>
        </Image>
   </Canvas> 


</Window>