Window level resource

   
       

<Window x:Class="Resources.WindowResource"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Resources" Height="300" Width="300"
    >
  <Window.Resources>
    <ImageBrush x:Key="TileBrush" TileMode="Tile"
                ViewportUnits="Absolute" Viewport="0 0 32 32"
                ImageSource="happyface.jpg" Opacity="0.3"></ImageBrush>
  </Window.Resources>
    <StackPanel Margin="5">
      <Button Background="{StaticResource TileBrush}" Padding="5"
              FontWeight="Bold" FontSize="14" Margin="5"
              >A Tiled Button</Button>
    </StackPanel>
</Window>

   
    
    
    
    
    
    
     


Use outter resource or inner resource

   
       

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

  <Window.Resources>
    <ImageBrush x:Key="TileBrush" TileMode="Tile"
                ViewportUnits="Absolute" Viewport="0 0 32 32"
                ImageSource="c:image.jpg" Opacity="0.3"></ImageBrush>
  </Window.Resources>
  <StackPanel Margin="5">
    
    <Button Background="{StaticResource TileBrush}" Padding="5"
            FontWeight="Bold" FontSize="14" Margin="5"
              >A Tiled Button</Button>

    <Button Padding="5" Margin="5" FontWeight="Bold" FontSize="14">
      <Button.Resources>
        <ImageBrush x:Key="TileBrush" TileMode="Tile"
                    ViewportUnits="Absolute" Viewport="0 0 10 10"
                    ImageSource="cimage.jpg" Opacity="0.3"></ImageBrush>
      </Button.Resources>
      <Button.Background><StaticResource ResourceKey="TileBrush" /></Button.Background>
      <Button.Content>Another Tiled Button</Button.Content>
    </Button>

  </StackPanel>

</Window>

   
    
    
    
    
    
    
     


Use outter resource or inner resource

   
       

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

  <Window.Resources>
    <ImageBrush x:Key="TileBrush" TileMode="Tile"
                ViewportUnits="Absolute" Viewport="0 0 32 32"
                ImageSource="c:image.jpg" Opacity="0.3"></ImageBrush>
  </Window.Resources>
  <StackPanel Margin="5">
    
    <Button Background="{StaticResource TileBrush}" Padding="5"
            FontWeight="Bold" FontSize="14" Margin="5"
              >A Tiled Button</Button>

    <Button Padding="5" Margin="5" FontWeight="Bold" FontSize="14">
      <Button.Resources>
        <ImageBrush x:Key="TileBrush" TileMode="Tile"
                    ViewportUnits="Absolute" Viewport="0 0 10 10"
                    ImageSource="cimage.jpg" Opacity="0.3"></ImageBrush>
      </Button.Resources>
      <Button.Background><StaticResource ResourceKey="TileBrush" /></Button.Background>
      <Button.Content>Another Tiled Button</Button.Content>
    </Button>

  </StackPanel>

</Window>

   
    
    
    
    
    
    
     


Set the slider value with RepeatButton


   
  

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="100" Width="200">
    <StackPanel>
        <Slider Name="slider" Maximum="100" Minimum="0" Value="50" />
        <StackPanel Orientation="Horizontal">
            <RepeatButton Click="SliderLeft_Click" Content="Click Me" 
                          Height="23" Margin="10" Width="70" 
                          ToolTip="Click to move slider left" />
            <RepeatButton Click="SliderRight_Click" ClickMode="Hover" 
                          Content="Touch Me" Height="23" Margin="10" 
                          ToolTip="Hover to move slider right" Width="70" />
        </StackPanel>
    </StackPanel>
</Window>
//File:Window.xaml.cs
using System.Windows;

namespace WpfApplication1
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
        private void SliderLeft_Click(object sender, RoutedEventArgs e)
        {
            slider.Value -= 1;
        }

        private void SliderRight_Click(object sender, RoutedEventArgs e)
        {
            slider.Value += 1;
        }
    }
}

   
    
     


RepeatButtons have their delay properties set to 500 milliseconds and their interval properties set to 100.


   
  



<DockPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="RepeatButtons.Pane1">
  <StackPanel>
      <RepeatButton Width="100" DockPanel.Dock="Top" 
                    Delay="500" Interval="100" 
                    Click="Increase">
        Increase
      </RepeatButton>
      <TextBlock Name="valueText" 
                 Width="100" DockPanel.Dock="Top" 
                 TextAlignment="Center" FontSize="16">
        0
      </TextBlock>

      <RepeatButton Width="100" DockPanel.Dock="Top" 
                    Delay="500" Interval="100" 
                    Click="Decrease">
        Decrease
      </RepeatButton>
    </StackPanel>
</DockPanel>

//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace RepeatButtons
{
    public partial class Pane1 : DockPanel
    {
        void Increase(object sender, RoutedEventArgs e)
        {
            Int32 Num = Convert.ToInt32(valueText.Text);

            valueText.Text = ((Num + 1).ToString());
        }

        void Decrease(object sender, RoutedEventArgs e)
        {
            Int32 Num = Convert.ToInt32(valueText.Text);

            valueText.Text = ((Num - 1).ToString());
        }
    }
}

   
    
     


Two repeat buttons that increase and decrease a numerical value.


   
  


<DockPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="RepeatButtons.Pane1">
  <StackPanel>
      <RepeatButton Width="100" DockPanel.Dock="Top" 
                    Delay="500" Interval="100" 
                    Click="Increase">
        Increase
      </RepeatButton>
      <TextBlock Name="valueText" 
                 Width="100" DockPanel.Dock="Top" 
                 TextAlignment="Center" FontSize="16">
        0
      </TextBlock>

      <RepeatButton Width="100" DockPanel.Dock="Top" 
                    Delay="500" Interval="100" 
                    Click="Decrease">
        Decrease
      </RepeatButton>
    </StackPanel>
</DockPanel>
//File:Window.xaml.cs


using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace RepeatButtons
{
    public partial class Pane1 : DockPanel
    {
        void Increase(object sender, RoutedEventArgs e)
        {
            Int32 Num = Convert.ToInt32(valueText.Text);

            valueText.Text = ((Num + 1).ToString());
        }

        void Decrease(object sender, RoutedEventArgs e)
        {
            Int32 Num = Convert.ToInt32(valueText.Text);

            valueText.Text = ((Num - 1).ToString());
        }
    }
}

   
    
     


Path with ScaleTransformation


   
    

<Window x:Class="Animation.KeySplineAnimation"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="KeySplineAnimation" Height="250" Width="600">
    <Canvas Margin="10">

        <Path Stroke="Blue" StrokeThickness="1" StrokeDashArray="2 1" Canvas.Top="25">
            <Path.Data>
                <PathGeometry>
                    <PathFigure>
                        <BezierSegment Point1="25,0" Point2="50,70" Point3="100,100" />
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
            <Path.RenderTransform>
                <ScaleTransform ScaleX="2.5"></ScaleTransform>
            </Path.RenderTransform>
        </Path>
        <Path Stroke="Blue" StrokeThickness="1" StrokeDashArray="2 1" Canvas.Left="250" Canvas.Top="25">
            <Path.Data>
                <PathGeometry>
                    <PathFigure>
                        <BezierSegment Point1="25,80" Point2="20,40" Point3="100,100" />
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
            <Path.RenderTransform>
                <ScaleTransform ScaleX="2.5"></ScaleTransform>
            </Path.RenderTransform>
        </Path>
    </Canvas>
</Window>