Posted By

qrist0ph on 08/26/08


Tagged

WPF studentWest xaml


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


WPF Template in Resource File


 / Published in: XML
 

  1. <Application x:Class="WpfApplication1.App"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. StartupUri="Window1.xaml">
  5. <Application.Resources>
  6. <ResourceDictionary>
  7. <ResourceDictionary.MergedDictionaries>
  8. <ResourceDictionary Source="Resource.xaml" />
  9. </ResourceDictionary.MergedDictionaries>
  10. </ResourceDictionary>
  11. </Application.Resources>
  12. </Application>
  13.  
  14.  
  15.  
  16. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  17. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  18. <ControlTemplate x:Key="buttonTemplate" TargetType="{x:Type Button}">
  19. <Grid>
  20. <Ellipse x:Name="outerCircle">
  21. <Ellipse.Fill>
  22. <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
  23. <GradientStop Offset="0" Color="Blue" />
  24. <GradientStop Offset="1" Color="Red" />
  25. </LinearGradientBrush>
  26. </Ellipse.Fill>
  27. </Ellipse>
  28. <Ellipse x:Name="innerCircle" RenderTransformOrigin=".5,.5">
  29. <Ellipse.RenderTransform>
  30. <ScaleTransform ScaleX=".8" ScaleY=".8" />
  31. </Ellipse.RenderTransform>
  32. <Ellipse.Fill>
  33. <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
  34. <GradientStop Offset="0" Color="Red" />
  35. <GradientStop Offset="1" Color="Blue" />
  36. </LinearGradientBrush>
  37. </Ellipse.Fill>
  38. </Ellipse>
  39. <Viewbox>
  40. <ContentPresenter Margin="{TemplateBinding Padding}" />
  41. </Viewbox>
  42. </Grid>
  43. <ControlTemplate.Triggers>
  44. <Trigger Property="IsMouseOver" Value="True">
  45. <Setter TargetName="outerCircle" Property="Fill" Value="Orange" />
  46. </Trigger>
  47. <Trigger Property="IsPressed" Value="True">
  48. <Setter Property="RenderTransform" >
  49. <Setter.Value>
  50. <ScaleTransform ScaleX=".9" ScaleY=".9" />
  51. </Setter.Value>
  52. </Setter>
  53. <Setter Property="RenderTransformOrigin" Value=".5,.5"/>
  54. </Trigger>
  55. </ControlTemplate.Triggers>
  56. </ControlTemplate>
  57.  
  58. <Style x:Key="buttonStyle" TargetType="{x:Type Button}">
  59. <Setter Property="Foreground" Value="Blue" />
  60. <Setter Property="Background" Value="Black" />
  61. <Setter Property="FontSize" Value="14" />
  62. </Style>
  63. </ResourceDictionary>
  64.  
  65.  
  66. <Grid>
  67. <Button Margin="275,112,241,106" Name="button1" Template="{StaticResource buttonTemplate}" Click="button1_Click">Text</Button>
  68. <Button Margin="275,0,241,59" Name="button2" Style="{StaticResource buttonStyle}" Click="button1_Click" Height="23" VerticalAlignment="Bottom">Text</Button>
  69. </Grid>

Report this snippet  

You need to login to post a comment.