Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. <Window x:Class="WpfButtonStyling.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. Title="MainWindow" Height="250" Width="400">
  5. <Window.Resources>
  6. <Style x:Key="ButtonStyle1"
  7. TargetType="{x:Type Button}">
  8. <Setter Property="Foreground"
  9. Value="Red" />
  10. <Setter Property="Margin"
  11. Value="10" />
  12. </Style>
  13. <Style x:Key="ButtonStyle2"
  14. TargetType="{x:Type Button}">
  15. <Setter Property="Foreground"
  16. Value="Blue" />
  17. <Setter Property="Margin"
  18. Value="10" />
  19. </Style>
  20. </Window.Resources>
  21.  
  22. <Grid>
  23. <StackPanel>
  24. <Button x:Name="FirstButton"
  25. Content="First!"
  26. Style="{StaticResource ButtonStyle1}"/>
  27. <Button x:Name="SecondButton"
  28. Content="Second"
  29. Style="{StaticResource ButtonStyle2}" />
  30. </StackPanel>
  31. </Grid>
  32. </Window>
  33.  
  34. <Window x:Class="WpfApplication1.MainWindow"
  35. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  36. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  37. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  38. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  39. HorizontalAlignment="Left"
  40. VerticalAlignment="Top">
  41. <Window.Resources>
  42. **<Style x:Key="a" TargetType="{x:Type TextBlock}">
  43. <Setter Property="FontFamily" Value="Verdana" />
  44. <Setter Property="FontSize" Value="50"/>
  45. <Setter Property="Background" Value="Indigo"/>
  46. </Style>
  47. <Style x:Key="b" TargetType="{x:Type TextBlock}">
  48. <Setter Property="FontFamily" Value="Arial"/>
  49. <Setter Property="FontSize" Value="16"/>
  50. </Style>
  51. <Style x:Key="c" TargetType="{x:Type Button}">
  52. <Setter Property="FontFamily" Value="TimesNewRoman" />
  53. <Setter Property="FontSize" Value="50"/>
  54. <Setter Property="Background" Value="Green"/>
  55. </Style>
  56. </Window.Resources>
  57. <Grid>
  58. <TextBlock Margin="26,41,39,0" Style="{StaticResource a}" Height="100" VerticalAlignment="Top">TextBlock with Style1</TextBlock>
  59. <TextBlock Margin="26,77,39,0" Height="32" VerticalAlignment="Top">TextBlock with no Style</TextBlock>
  60. <TextBlock Margin="26,105,67,96" Style="{StaticResource b}">TextBlock with Style2</TextBlock>
  61. <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="26,170,-26,0">
  62. <Button Style="{StaticResource c}">
  63. <Bold >Styles</Bold></Button>
  64. <Button Style="{StaticResource c}">are</Button>
  65. <Button Style="{StaticResource c}">cool</Button>
  66. </StackPanel>
  67. </Grid>
  68.  
  69. <Button>
  70. <Button.Style>
  71. <Style TargetType="{x:Type Button}">
  72. <Setter Property="FontFamily" Value="TimesNewRoman" />
  73. <Setter Property="FontSize" Value="50"/>
  74. <Setter Property="Background" Value="Green"/>
  75. </Style>
  76. </Button.Style>
  77. </Button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement