XAML code
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="CustomButtonEffects.MainPage"
Width="640" Height="325" mc:Ignorable="d">
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF353535" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TextBlock Height="53" Margin="124,0,120,71" VerticalAlignment="Bottom" FontSize="34.667" TextWrapping="Wrap" HorizontalAlignment="Center" FontFamily="Fonts/Fonts.zip#Myriad Pro">
<TextBlock.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFE0E0E0" Offset="0"/>
<GradientStop Color="#FF585858" Offset="1"/>
</LinearGradientBrush>
</TextBlock.Foreground>
<TextBlock.Effect>
<DropShadowEffect BlurRadius="2" Opacity="0.5" ShadowDepth="2"/>
</TextBlock.Effect>
<Run Text="Custom Button Effects"/>
<LineBreak/>
</TextBlock>
<TextBlock Height="52" Margin="161,0,157,19" VerticalAlignment="Bottom" FontSize="16" Foreground="White" TextWrapping="Wrap" FontFamily="Fonts/Fonts.zip#Myriad Pro" Text="Rollover the buttons to see the effect ." TextAlignment="Center"/>
<Button Margin="220,69,220,155" Style="{StaticResource ButtonImageGradient}" Content="Button"/>
<Button Margin="18,69,0,155" Style="{StaticResource ButtonImageGradient}" Content="Button" HorizontalAlignment="Left" Width="200"/>
<Button Margin="0,69,18,155" Style="{StaticResource ButtonImageGradient}" Content="Button" HorizontalAlignment="Right" Width="200"/>
</Grid>
</UserControl>
XAML code – Resource Dictionary
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<!-- Resource dictionary entries should be defined here. -->
<Style x:Key="ButtonImageGradient" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Canvas>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.3000000">
<VisualTransition.GeneratedEasingFunction>
<CubicEase EasingMode="EaseIn"/>
</VisualTransition.GeneratedEasingFunction>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BorderOutline" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#7E575757"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BorderOutline" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ButtonGradient" Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Height="100" Source="Image1.png" Stretch="Fill"/>
<Rectangle x:Name="ButtonGradient" Height="100" Width="200">
<Rectangle.Fill>
<RadialGradientBrush RadiusX="0.657" RadiusY="0.617">
<GradientStop Offset="0"/>
<GradientStop Color="#C1000000" Offset="1"/>
</RadialGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="BorderOutline" Fill="{x:Null}" Stroke="#7E808080" Height="101" Width="200"/>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>











May 9th, 2010 at 2:45 pm
Nice article. Step 5 should be “Make into Control” instead of “Make into UserControl”..