Stroke Start Line Cap


   
      
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="FontSize" Value="16" />
            <Setter Property="Margin" Value="24" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <Style TargetType="{x:Type Line}">
            <Setter Property="Grid.Column" Value="1" />
            <Setter Property="Y1" Value="3" />
            <Setter Property="X2" Value="400" />
            <Setter Property="Y2" Value="30" />
            <Setter Property="StrokeThickness" Value="25" />
            <Setter Property="Stroke" Value="Black" />
            <Setter Property="StrokeDashArray" Value="2 2 3 4" />

            <Setter Property="StrokeStartLineCap" Value="{Binding RelativeSource={RelativeSource self}, Path=StrokeDashCap}" />

            <Setter Property="StrokeEndLineCap" Value="{Binding RelativeSource={RelativeSource self}, Path=StrokeDashCap}" />

        </Style>
    </Grid.Resources>

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>

    <!-- PenLineCap.Flat. -->
    <TextBlock Grid.Row="0" Text="PenLineCap.Flat" />
    <Line Grid.Row="0" />

    <!-- PenLineCap.Square. -->
    <TextBlock Grid.Row="1" Text="PenLineCap.Square" />
    <Line Grid.Row="1" StrokeDashCap="Square" />

    <!-- PenLineCap.Round. -->
    <TextBlock Grid.Row="2" Text="PenLineCap.Round" />
    <Line Grid.Row="2" StrokeDashCap="Round" />

    <!-- Triangle.Triangle. -->
    <TextBlock Grid.Row="3" Text="PenLineCap.Triangle" />
    <Line Grid.Row="3" StrokeDashCap="Triangle" />
</Grid>

   
    
    
    
    
    
     


Normal: Origin at upper left


   
      
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="100" />
            <Setter Property="Height" Value="100" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <Style TargetType="{x:Type Path}">
            <Setter Property="Fill" Value="Red" />
            <Setter Property="Data">
                <Setter.Value>
                    <EllipseGeometry Center="0 0" RadiusX="5" RadiusY="5" />
                </Setter.Value>
            </Setter>
        </Style>
    </Grid.Resources>
    <Canvas Grid.Column="0">
        <Line X1="0" Y1="0" X2="100" Y2="100" Stroke="Black" />
        <Polyline Points="0 0 0 100 100 100 100 0 0 0" Stroke="Blue" />
        <Path />
    </Canvas>

</Grid>

   
    
    
    
    
    
     


Style Slider: Background, IsSnapToTickEnabled, AutoToolTipPlacement, TickFrequency


   
     
<Window x:Class="ScrollBarCustomThumbSize.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib" 
    Title="" >
    <Window.Resources>
        <Style  TargetType="{x:Type Slider}">
            <Setter Property = "Background" Value = "Red"/>
            <Setter Property = "IsSnapToTickEnabled" Value ="True"/>
            <Setter Property = "TickPlacement" Value ="BottomRight"/>
            <Setter Property = "AutoToolTipPlacement" Value ="BottomRight"/>
            <Setter Property = "TickFrequency" Value ="1"/>
        </Style>


    </Window.Resources>

    <Grid>
        <Slider></Slider>


    </Grid>

</Window>

   
    
    
    
    
     


Style With Triggers


   
    

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel.Resources>
        <Style x:Key="normal">
            <Setter Property="Control.FontSize" Value="24" />
            <Setter Property="Control.HorizontalAlignment" Value="Center" />
            <Setter Property="Control.Margin" Value="24" />

            <Style.Triggers>
                <Trigger Property="Control.IsMouseOver" Value="true">
                    <Setter Property="Control.FontStyle" Value="Italic" />
                    <Setter Property="Control.Foreground" Value="Blue" />
                </Trigger>

                <Trigger Property="Button.IsPressed" Value="true">
                    <Setter Property="Control.Foreground" Value="Red" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </StackPanel.Resources>

    <Button Style="{StaticResource normal}">
        Button Number 1
    </Button>
</StackPanel>

   
    
    
    
     


Style With Property Element


   
    

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel.Resources>
        <Style x:Key="normal">
            <Setter Property="Control.FontSize" Value="24" />
            <Setter Property="Control.HorizontalAlignment" Value="Center" />
            <Setter Property="Control.Margin" Value="24" />
            <Setter Property="Control.Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="1,0" EndPoint="1,1">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="LightBlue" Offset="0" />
                            <GradientStop Color="Aquamarine" Offset="1" />
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>
    </StackPanel.Resources>

    <Button Style="{StaticResource normal}">
        Button Number 1
    </Button>
</StackPanel>

   
    
    
    
     


Style With Resource


   
    

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel.Resources>
        <Style x:Key="normal">
            <Style.Resources>
                <LinearGradientBrush x:Key="gradbrush" StartPoint="1,0" EndPoint="1,1">
                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="LightBlue" Offset="0" />
                        <GradientStop Color="Aquamarine" Offset="1" />
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Style.Resources>
            <Setter Property="Control.FontSize" Value="24" />
            <Setter Property="Control.HorizontalAlignment" Value="Center" />
            <Setter Property="Control.Margin" Value="24" />
            <Setter Property="Control.Background" Value="{StaticResource gradbrush}" />
        </Style>
    </StackPanel.Resources>

    <Button Style="{StaticResource normal}">
        Button Number 1
    </Button>
</StackPanel>

   
    
    
    
     


Style With Multiple Buttons


   
    

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel.Resources>
        <Style x:Key="normal">
            <Setter Property="Control.FontSize" Value="24" />
            <Setter Property="Control.Foreground" Value="Blue" />
            <Setter Property="Control.HorizontalAlignment" Value="Center" />
            <Setter Property="Control.Margin" Value="24" />
            <Setter Property="Control.Padding" Value="20, 10, 20, 10" />
        </Style>
    </StackPanel.Resources>

    <Button Style="{StaticResource normal}">
        Button Number 1
    </Button>

</StackPanel>