<UserControl x:Class="CustomControls.PushButton"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:CustomControls"
             mc:Ignorable="d" 
             d:DesignHeight="60" d:DesignWidth="120">

    <UserControl.Resources>
        <!--#region  Push button template-->
        <Style x:Key="PushbuttonBackground" TargetType="Border">
            <Setter Property="Background" Value="{StaticResource GreenFade}"/>
        </Style>

        <Style x:Key="StripeOverlay" TargetType="Rectangle">
            <Setter Property="Fill">
                <Setter.Value>
                    <VisualBrush  TileMode="Tile" Viewport="0,0,4,4"
                   Viewbox="0,0,10,10" ViewportUnits="Absolute" 
                   ViewboxUnits="Absolute">
                        <VisualBrush.Visual>
                            <Line X1="10" X2="0" Y1="0" Y2="10" Stroke="Black" Opacity="0.2"/>
                        </VisualBrush.Visual>
                    </VisualBrush>
                </Setter.Value>
            </Setter>
        </Style>

        <ControlTemplate x:Key="PushButtonTemplate" TargetType="{x:Type Button}">

            <Grid x:Name="RootGrid" RenderTransformOrigin="0.5,0.5" >

                <Grid.OpacityMask>
                    <VisualBrush Visual="{Binding ElementName=Border1}" />
                </Grid.OpacityMask>

                <Border x:Name="Border1" CornerRadius="7" BorderThickness="0" ClipToBounds="true" Style="{StaticResource PushbuttonBackground}" >
                    <Rectangle Style="{StaticResource StripeOverlay}" Margin="0,0,0,0" RadiusX="6" RadiusY="6" Stroke="#224F4F"  />
                </Border>

                <TextBlock Text="{TemplateBinding Content}" >
                    <TextBlock.Style>
                        <Style  TargetType="{x:Type TextBlock}">
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="HorizontalAlignment" Value="Center"/>
                            <Setter Property="TextAlignment" Value="Center"/>
                            <Setter Property="TextWrapping" Value="Wrap"/>
                            <Setter Property="Foreground" Value="White"/>
                            <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=FontSize, FallbackValue=18}"/>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property ="IsPressed"  Value ="True">
                    <Setter TargetName ="RootGrid"  Property="RenderTransform">
                        <Setter.Value>
                            <ScaleTransform ScaleX="0.95" ScaleY="0.95"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <!--#endregion-->
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" >       
            <Button Template="{StaticResource PushButtonTemplate}"  Command="{Binding Command}" CommandParameter="{Binding CommandPar}" Content="{Binding Text}" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Focusable="False"/>
    </Grid>
</UserControl>
