Draw second figure with “NonZero” FillRule


   
     

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        TextBlock.FontSize="16">
    <Canvas.Resources>
        <Style x:Key="star">
            <Setter Property="Polygon.Points"
                    Value="0 -96, 56, 78, -91 -30, 91 -30, -56 78" />
            <Setter Property="Polygon.Fill"
                    Value="Blue" />
            <Setter Property="Polygon.Stroke"
                    Value="Red" />
            <Setter Property="Polygon.StrokeThickness"
                    Value="3" />
        </Style>
    </Canvas.Resources>
    <TextBlock Canvas.Left="288" Canvas.Top="24"
               Text="FillRule = NonZero" />
 
    <Polygon Style="{StaticResource star}"
             FillRule="NonZero"
             Canvas.Left="360" Canvas.Top="168" />
</Canvas>

   
    
    
    
    
     


Draw figure with “NonZero” FillRule

   
     
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        TextBlock.FontSize="16">
    <Canvas.Resources>
        <Style x:Key="figure">
            <Setter Property="Polygon.Points"
                    Value="0 48, 0 144, 96 150, 100 0, 192 0, 192 96, 50 96, 48 192, 150 200 144 48" />
            <Setter Property="Polygon.Fill"
                    Value="Black" />
            <Setter Property="Polygon.Stroke"
                    Value="Yellow" />
            <Setter Property="Polygon.StrokeThickness"
                    Value="3" />
        </Style>
    </Canvas.Resources>

    <TextBlock Canvas.Left="288" Canvas.Top="24"
               Text="FillRule = NonZero" />

    <Polygon Style="{StaticResource figure}"
             FillRule="NonZero"
             Canvas.Left="288" Canvas.Top="72" />
</Canvas>

   
    
    
    
    
     


Draw figure with “EvenOdd” FillRule


   
     

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        TextBlock.FontSize="16">
    <Canvas.Resources>
        <Style x:Key="figure">
            <Setter Property="Polygon.Points"
                    Value="0 48, 0 150, 96 150, 96 0, 200 0, 200 100, 48 96, 48 192, 144 192 144 48" />
            <Setter Property="Polygon.Fill"
                    Value="Blue" />
            <Setter Property="Polygon.Stroke"
                    Value="Red" />
            <Setter Property="Polygon.StrokeThickness"
                    Value="3" />
        </Style>
    </Canvas.Resources>

    <TextBlock Canvas.Left="48" Canvas.Top="24"
               Text="FillRule = EvenOdd" />

    <Polygon Style="{StaticResource figure}"
             FillRule="EvenOdd"
             Canvas.Left="48" Canvas.Top="72" />
</Canvas>

   
    
    
    
    
     


Specifying points the long way with Polygon.Points tag and Point


   
     
<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
    <StackPanel Orientation="Horizontal">
        <Polygon Fill="Red" >
            <Polygon.Points>
                <Point X="20" Y="0"/>
                <Point X="40" Y="40"/>
                <Point X="0" Y="40"/>
            </Polygon.Points>
        </Polygon>

    </StackPanel>
</Window>

   
    
    
    
    
     


A Polygon always closes the end points


   
     
<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WpfApplication1" Height="352" Width="334" WindowStartupLocation="CenterScreen">
    <StackPanel>
    <Polygon Fill ="AliceBlue" StrokeThickness ="5" 
               Stroke ="Green" 
               Points ="40,10 70,80 10,50" />
    </StackPanel>
</Window>