Dotted Path


   
  
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:MyNameSpace.TextGeometryDemo" 
        Title="TextGeometry Demo">
    <Window.Resources>
        <src:TextGeometry x:Key="txtHollow" Text="Hollow"
                          FontFamily="Times New Roman" 
                          FontSize="192" FontWeight="Bold" />
        
        <src:TextGeometry x:Key="txtShadow" Text="Shadow"
                          FontFamily="Times New Roman"
                          FontSize="192" FontWeight="Bold" />
    </Window.Resources>

    <TabControl>
        <TabItem Header="Dotted">
            <Path Stroke="Blue" StrokeThickness="5"
                  StrokeDashArray="{Binding Source={x:Static DashStyles.Dot},Path=Dashes}"
                  StrokeDashCap="Round"
                  Data="{Binding Source={StaticResource txtHollow},Path=Geometry}" />
        </TabItem>


    </TabControl>
</Window>
//File:Window.xaml.cs
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;

namespace MyNameSpace.TextGeometryDemo
{
    public class TextGeometry
    {
        string txt = "";
        FontFamily fntfam = new FontFamily();
        FontStyle fntstyle = FontStyles.Normal;
        FontWeight fntwt = FontWeights.Normal;
        FontStretch fntstr = FontStretches.Normal;
        double emsize = 24;
        Point ptOrigin = new Point(0, 0);

        public string Text
        {
            set { txt = value; }
            get { return txt; }
        }
        public FontFamily FontFamily
        {
            set { fntfam = value; }
            get { return fntfam; }
        }
        public FontStyle FontStyle
        {
            set { fntstyle = value; }
            get { return fntstyle; }
        }
        public FontWeight FontWeight
        {
            set { fntwt = value; }
            get { return fntwt; }
        }
        public FontStretch FontStretch
        {
            set { fntstr = value; }
            get { return fntstr; }
        }
        public double FontSize
        {
            set { emsize = value; }
            get { return emsize; }
        }
        public Point Origin
        {
            set { ptOrigin = value; }
            get { return ptOrigin; }
        }

        public Geometry Geometry
        {
            get
            {
                FormattedText formtxt = new FormattedText(Text, CultureInfo.CurrentCulture, 
                                      FlowDirection.LeftToRight,
                                      new Typeface(FontFamily, FontStyle,FontWeight, FontStretch), 
                                      FontSize, Brushes.Black);

                return formtxt.BuildGeometry(Origin);
            }
        }

        public PathGeometry PathGeometry
        {
            get
            {
                return PathGeometry.CreateFromGeometry(Geometry);
            }
        }

    }
}

   
    
     


StrokeStartLineCap=Round, StrokeEndLineCap=Round


   
             

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Use ListBox" Height="300" Width="300">

    <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    
      <Line X1="75" Y1="160" X2="175" Y2="150" 
            StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stroke="Black" StrokeThickness="10"/>

    </Canvas>

</Window>

   
    
    
    
    
    
    
    
    
    
    
    
    
     


PenLineCap.Triangle


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">
    <StackPanel.Resources>
        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="150" />
            <Setter Property="Margin" Value="12" />
        </Style> 

        <Style x:Key="thin">
            <Setter Property="Line.X1" Value="00" />
            <Setter Property="Line.Y1" Value="50" />
            <Setter Property="Line.X2" Value="100" />
            <Setter Property="Line.Y2" Value="50" />
            <Setter Property="Line.Stroke" Value="Black" />
        </Style>

        <Style x:Key="thick"
               BasedOn="{StaticResource thin}">
            <Setter Property="Line.Stroke" Value="LightGray" />
            <Setter Property="Line.StrokeThickness" Value="25" />
        </Style>
    </StackPanel.Resources>

    <Canvas>
        <TextBlock Text="PenLineCap.Triangle" />
        <Line Style="{StaticResource thick}"
              StrokeStartLineCap="Triangle"
              StrokeEndLineCap="Triangle" />
        <Line Style="{StaticResource thin}" />
    </Canvas>
                
</StackPanel>

   
    
    
     


PenLineCap.Round


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">
    <StackPanel.Resources>
        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="150" />
            <Setter Property="Margin" Value="12" />
        </Style> 

        <Style x:Key="thin">
            <Setter Property="Line.X1" Value="00" />
            <Setter Property="Line.Y1" Value="50" />
            <Setter Property="Line.X2" Value="100" />
            <Setter Property="Line.Y2" Value="50" />
            <Setter Property="Line.Stroke" Value="Black" />
        </Style>

        <Style x:Key="thick"
               BasedOn="{StaticResource thin}">
            <Setter Property="Line.Stroke" Value="LightGray" />
            <Setter Property="Line.StrokeThickness" Value="25" />
        </Style>
    </StackPanel.Resources>

    <Canvas>
        <TextBlock Text="PenLineCap.Round" />
        <Line Style="{StaticResource thick}"
              StrokeStartLineCap="Round"
              StrokeEndLineCap="Round" />
        <Line Style="{StaticResource thin}" />
    </Canvas>
                
</StackPanel>

   
    
    
     


PenLineCap.Square


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">
    <StackPanel.Resources>
        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="150" />
            <Setter Property="Margin" Value="12" />
        </Style> 

        <Style x:Key="thin">
            <Setter Property="Line.X1" Value="00" />
            <Setter Property="Line.Y1" Value="50" />
            <Setter Property="Line.X2" Value="100" />
            <Setter Property="Line.Y2" Value="50" />
            <Setter Property="Line.Stroke" Value="Black" />
        </Style>

        <Style x:Key="thick"
               BasedOn="{StaticResource thin}">
            <Setter Property="Line.Stroke" Value="LightGray" />
            <Setter Property="Line.StrokeThickness" Value="25" />
        </Style>
    </StackPanel.Resources>

    <Canvas>
        <TextBlock Text="PenLineCap.Square" />
        <Line Style="{StaticResource thick}"
              StrokeStartLineCap="Square"
              StrokeEndLineCap="Square" />
        <Line Style="{StaticResource thin}" />
    </Canvas>
                
</StackPanel>

   
    
    
     


PenLineCap.Flat


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">
    <StackPanel.Resources>
        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="150" />
            <Setter Property="Margin" Value="12" />
        </Style> 

        <Style x:Key="thin">
            <Setter Property="Line.X1" Value="00" />
            <Setter Property="Line.Y1" Value="50" />
            <Setter Property="Line.X2" Value="100" />
            <Setter Property="Line.Y2" Value="50" />
            <Setter Property="Line.Stroke" Value="Black" />
        </Style>

        <Style x:Key="thick"
               BasedOn="{StaticResource thin}">
            <Setter Property="Line.Stroke" Value="LightGray" />
            <Setter Property="Line.StrokeThickness" Value="25" />
        </Style>
    </StackPanel.Resources>

    <Canvas>
        <TextBlock Text="PenLineCap.Flat" />
        <Line Style="{StaticResource thick}"
              StrokeStartLineCap="Flat"
              StrokeEndLineCap="Flat" />
        <Line Style="{StaticResource thin}" />
    </Canvas>

                
</StackPanel>

   
    
    
     


PenLineJoin.Miter


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">
    <StackPanel.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Canvas.Left" Value="25" />
        </Style>

        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="150" />
            <Setter Property="Margin" Value="12" />
        </Style> 

        <Style TargetType="{x:Type Rectangle}">
            <Setter Property="Width" Value="100" />
            <Setter Property="Height" Value="100" />
            <Setter Property="Canvas.Top" Value="50" />
            <Setter Property="Canvas.Left" Value="25" />
            <Setter Property="Stroke" Value="Black" />
            <Setter Property="StrokeThickness" Value="25" />
        </Style>
    </StackPanel.Resources>

    <Canvas>
        <TextBlock Text="PenLineJoin.Miter" />
        <Rectangle StrokeLineJoin="Miter" />
    </Canvas>

</StackPanel>