GroupBoxBaseStyle.xaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:hc="clr-namespace:HandyControl.Controls">
  2. <ControlTemplate x:Key="GroupBoxBaseTopTemplate" TargetType="GroupBox">
  3. <Grid>
  4. <Grid.RowDefinitions>
  5. <RowDefinition Height="Auto" />
  6. <RowDefinition />
  7. </Grid.RowDefinitions>
  8. <Border MinHeight="{Binding Path=(hc:TitleElement.MinHeight), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,6">
  9. <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  10. </Border>
  11. <Border Grid.Row="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  12. <ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  13. </Border>
  14. </Grid>
  15. </ControlTemplate>
  16. <ControlTemplate x:Key="GroupBoxBaseLeftTemplate" TargetType="GroupBox">
  17. <Grid>
  18. <Grid.ColumnDefinitions>
  19. <ColumnDefinition Width="Auto" />
  20. <ColumnDefinition />
  21. </Grid.ColumnDefinitions>
  22. <Border MinWidth="{Binding Path=(hc:TitleElement.MinWidth), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="False" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,6,0">
  23. <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RenderTransformOrigin="0.5,0.5">
  24. <ContentPresenter.LayoutTransform>
  25. <TransformGroup>
  26. <RotateTransform Angle="-90" />
  27. </TransformGroup>
  28. </ContentPresenter.LayoutTransform>
  29. </ContentPresenter>
  30. </Border>
  31. <Border Grid.Column="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  32. <ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  33. </Border>
  34. </Grid>
  35. </ControlTemplate>
  36. <Style x:Key="GroupBoxBaseStyle" TargetType="GroupBox">
  37. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
  38. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}" />
  39. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
  40. <Setter Property="hc:TitleElement.Background" Value="{DynamicResource SecondaryRegionBrush}" />
  41. <Setter Property="hc:TitleElement.TitlePlacement" Value="Top" />
  42. <Setter Property="hc:TitleElement.Padding" Value="4 0" />
  43. <Setter Property="hc:TitleElement.MinHeight" Value="{StaticResource DefaultControlHeight}" />
  44. <Setter Property="hc:TitleElement.MinWidth" Value="{StaticResource DefaultControlHeight}" />
  45. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
  46. <Setter Property="VerticalContentAlignment" Value="Center" />
  47. <Setter Property="HorizontalContentAlignment" Value="Center" />
  48. <Setter Property="BorderThickness" Value="1" />
  49. <Setter Property="Padding" Value="4" />
  50. <Setter Property="Template" Value="{StaticResource GroupBoxBaseTopTemplate}" />
  51. <Style.Triggers>
  52. <Trigger Property="hc:TitleElement.TitlePlacement" Value="Left">
  53. <Setter Property="Template" Value="{StaticResource GroupBoxBaseLeftTemplate}" />
  54. <Setter Property="hc:TitleElement.Padding" Value="0 4" />
  55. </Trigger>
  56. </Style.Triggers>
  57. </Style>
  58. <ControlTemplate x:Key="GroupBoxOriginalTopTemplate" TargetType="GroupBox">
  59. <Grid>
  60. <Grid.RowDefinitions>
  61. <RowDefinition Height="Auto" />
  62. <RowDefinition />
  63. </Grid.RowDefinitions>
  64. <StackPanel Orientation="Horizontal" Margin="8,6">
  65. <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="1,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  66. <ContentPresenter TextElement.Foreground="{DynamicResource DangerBrush}" Margin="4,0,0,0" Content="{Binding Path=(hc:InfoElement.Symbol),RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=(hc:InfoElement.Necessary),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" />
  67. </StackPanel>
  68. <Border Grid.Row="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  69. <ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  70. </Border>
  71. </Grid>
  72. </ControlTemplate>
  73. <ControlTemplate x:Key="GroupBoxOriginalLeftTemplate" TargetType="GroupBox">
  74. <Grid>
  75. <Grid.ColumnDefinitions>
  76. <ColumnDefinition Width="{Binding Path=(hc:InfoElement.TitleWidth),RelativeSource={RelativeSource TemplatedParent}}" />
  77. <ColumnDefinition />
  78. </Grid.ColumnDefinitions>
  79. <StackPanel Orientation="Horizontal" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0,8,6,8">
  80. <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  81. <ContentPresenter TextElement.Foreground="{DynamicResource DangerBrush}" Margin="4,0,0,0" Content="{Binding Path=(hc:InfoElement.Symbol),RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=(hc:InfoElement.Necessary),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" />
  82. </StackPanel>
  83. <Border Grid.Column="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  84. <ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  85. </Border>
  86. </Grid>
  87. </ControlTemplate>
  88. <Style x:Key="GroupBoxOriginalBaseStyle" BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox">
  89. <Setter Property="hc:BorderElement.CornerRadius" Value="0" />
  90. <Setter Property="VerticalContentAlignment" Value="Top" />
  91. <Setter Property="Background" Value="Transparent" />
  92. <Setter Property="BorderThickness" Value="0" />
  93. <Setter Property="Padding" Value="0" />
  94. <Setter Property="Template" Value="{StaticResource GroupBoxOriginalTopTemplate}" />
  95. <Style.Triggers>
  96. <Trigger Property="hc:TitleElement.TitlePlacement" Value="Left">
  97. <Setter Property="Template" Value="{StaticResource GroupBoxOriginalLeftTemplate}" />
  98. </Trigger>
  99. </Style.Triggers>
  100. </Style>
  101. <ControlTemplate x:Key="GroupBoxTabTopTemplate" TargetType="GroupBox">
  102. <Grid>
  103. <Grid.RowDefinitions>
  104. <RowDefinition Height="Auto" />
  105. <RowDefinition />
  106. </Grid.RowDefinitions>
  107. <Border Grid.Row="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,0,1,1'}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  108. <ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  109. </Border>
  110. <Border Grid.Row="0" MinHeight="{Binding Path=(hc:TitleElement.MinHeight), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource ThicknessSplitConverter},ConverterParameter='1,1,1,0'}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,1,0,0'}">
  111. <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  112. </Border>
  113. </Grid>
  114. </ControlTemplate>
  115. <ControlTemplate x:Key="GroupBoxTabLeftTemplate" TargetType="GroupBox">
  116. <Grid>
  117. <Grid.ColumnDefinitions>
  118. <ColumnDefinition Width="Auto" />
  119. <ColumnDefinition />
  120. </Grid.ColumnDefinitions>
  121. <Border Grid.Column="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,1,1,0'}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  122. <ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  123. </Border>
  124. <Border Grid.Column="0" MinWidth="{Binding Path=(hc:TitleElement.MinWidth), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource ThicknessSplitConverter},ConverterParameter='1,1,0,1'}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,0,0,1'}">
  125. <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  126. <ContentPresenter.LayoutTransform>
  127. <TransformGroup>
  128. <RotateTransform Angle="-90" />
  129. </TransformGroup>
  130. </ContentPresenter.LayoutTransform>
  131. </ContentPresenter>
  132. </Border>
  133. </Grid>
  134. </ControlTemplate>
  135. <Style x:Key="GroupBoxTabBaseStyle" BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox">
  136. <Setter Property="Template" Value="{StaticResource GroupBoxTabTopTemplate}" />
  137. <Style.Triggers>
  138. <Trigger Property="hc:TitleElement.TitlePlacement" Value="Left">
  139. <Setter Property="Template" Value="{StaticResource GroupBoxTabLeftTemplate}" />
  140. <Setter Property="hc:TitleElement.Padding" Value="0 4" />
  141. </Trigger>
  142. </Style.Triggers>
  143. </Style>
  144. </ResourceDictionary>