GroupBoxStyle.xaml 6.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:converters="clr-namespace:Aitex.Core.UI.Converters">
  4. <Style TargetType="GroupBox">
  5. <Setter Property="FontSize" Value="20" />
  6. <Setter Property="BorderBrush" Value="Black" />
  7. </Style>
  8. <converters:CenterBorderGapMaskConverter x:Key="BorderGapMaskConverter"/>
  9. <Style x:Key="GroupboxWithoutWhiteBorder" TargetType="{x:Type GroupBox}">
  10. <Setter Property="BorderBrush" Value="#D5DFE5" />
  11. <Setter Property="BorderThickness" Value="1" />
  12. <Setter Property="Template">
  13. <Setter.Value>
  14. <ControlTemplate TargetType="{x:Type GroupBox}">
  15. <Grid SnapsToDevicePixels="true">
  16. <Grid.ColumnDefinitions>
  17. <ColumnDefinition Width="6" />
  18. <ColumnDefinition Width="Auto" />
  19. <ColumnDefinition Width="*" />
  20. <ColumnDefinition Width="6" />
  21. </Grid.ColumnDefinitions>
  22. <Grid.RowDefinitions>
  23. <RowDefinition Height="Auto" />
  24. <RowDefinition Height="Auto" />
  25. <RowDefinition Height="*" />
  26. <RowDefinition Height="6" />
  27. </Grid.RowDefinitions>
  28. <Border CornerRadius="4" Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Background="{TemplateBinding Background}" />
  29. <Border Name="Header" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2" Grid.Column="1">
  30. <ContentPresenter ContentSource="Header" RecognizesAccessKey="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  31. </Border>
  32. <ContentPresenter Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  33. <Border Grid.Row="1" Grid.RowSpan="3" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3">
  34. <Border.OpacityMask>
  35. <MultiBinding Converter="{StaticResource BorderGapMaskConverter}" ConverterParameter="7">
  36. <Binding ElementName="Header" Path="ActualWidth" />
  37. <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
  38. <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
  39. </MultiBinding>
  40. </Border.OpacityMask>
  41. </Border>
  42. </Grid>
  43. </ControlTemplate>
  44. </Setter.Value>
  45. </Setter>
  46. </Style>
  47. <Style x:Key="GroupboxWithoutWhiteBorder2" TargetType="{x:Type GroupBox}">
  48. <Setter Property="BorderBrush" Value="#D5DFE5"/>
  49. <Setter Property="BorderThickness" Value="1"/>
  50. <Setter Property="FontSize" Value="20" />
  51. <Setter Property="Foreground" Value="White"></Setter>
  52. <Setter Property="Template">
  53. <Setter.Value>
  54. <ControlTemplate TargetType="{x:Type GroupBox}">
  55. <Grid SnapsToDevicePixels="true">
  56. <Grid.ColumnDefinitions>
  57. <ColumnDefinition Width="6"/>
  58. <ColumnDefinition Width="Auto"/>
  59. <ColumnDefinition Width="*"/>
  60. <ColumnDefinition Width="6"/>
  61. </Grid.ColumnDefinitions>
  62. <Grid.RowDefinitions>
  63. <RowDefinition Height="Auto"/>
  64. <RowDefinition Height="Auto"/>
  65. <RowDefinition Height="*"/>
  66. <RowDefinition Height="6"/>
  67. </Grid.RowDefinitions>
  68. <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="4" Grid.Column="0" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3"/>
  69. <Border Grid.ZIndex="2" x:Name="Header" Grid.Column="2" HorizontalAlignment="Center" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2">
  70. <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  71. </Border>
  72. <ContentPresenter Grid.ColumnSpan="2" Grid.Column="1" Margin="{TemplateBinding Padding}" Grid.Row="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  73. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" CornerRadius="3" Grid.Row="1" Grid.RowSpan="3">
  74. <Border.OpacityMask>
  75. <MultiBinding ConverterParameter="7" Converter="{StaticResource BorderGapMaskConverter}">
  76. <Binding ElementName="Header" Path="ActualWidth"/>
  77. <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
  78. <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
  79. </MultiBinding>
  80. </Border.OpacityMask>
  81. <!--<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
  82. <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
  83. </Border>-->
  84. </Border>
  85. </Grid>
  86. </ControlTemplate>
  87. </Setter.Value>
  88. </Setter>
  89. </Style>
  90. </ResourceDictionary>