ComboBoxStyles.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <Styles
  2. xmlns="https://github.com/avaloniaui"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:glassMorphism="clr-namespace:SukiUI.Controls.GlassMorphism"
  5. xmlns:suki="https://github.com/kikipoulet/SukiUI"
  6. xmlns:theme="clr-namespace:SukiUI.Theme">
  7. <Design.PreviewWith>
  8. <Border Padding="20" Background="Transparent">
  9. <StackPanel
  10. Background="AliceBlue"
  11. Orientation="Horizontal"
  12. Spacing="10">
  13. <TextBox Text="TEst" />
  14. <ComboBox Margin="0,0,50,0" PlaceholderText="Select an item">
  15. <ComboBoxItem>Item 1</ComboBoxItem>
  16. <ComboBoxItem>Item 2</ComboBoxItem>
  17. </ComboBox>
  18. <ComboBox
  19. Width="200"
  20. HorizontalContentAlignment="Center"
  21. IsEnabled="False"
  22. SelectedIndex="1">
  23. <ComboBoxItem>Item 1</ComboBoxItem>
  24. <ComboBoxItem>Item 2</ComboBoxItem>
  25. </ComboBox>
  26. </StackPanel>
  27. </Border>
  28. </Design.PreviewWith>
  29. <Style Selector="ComboBox">
  30. <Setter Property="BorderThickness" Value="1,1,1,1" />
  31. <Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
  32. <Setter Property="CornerRadius" Value="{DynamicResource SmallCornerRadius}" />
  33. <Setter Property="Background" Value="{DynamicResource SukiBackground}" />
  34. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  35. <Setter Property="VerticalContentAlignment" Value="Center" />
  36. <Setter Property="Padding" Value="6,6,-6,6" />
  37. <Setter Property="MinHeight" Value="45" />
  38. <Setter Property="PlaceholderForeground" Value="{DynamicResource SukiLowText}" />
  39. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
  40. <Setter Property="Template">
  41. <ControlTemplate>
  42. <Border Margin="0,0,0,0" Padding="5">
  43. <Border.Styles>
  44. <Style Selector="ContentControl.ghost TextBlock">
  45. <Setter Property="Foreground" Value="Transparent" />
  46. </Style>
  47. <Style Selector="ToggleButton:pointerover">
  48. <Setter Property="Background" Value="Transparent" />
  49. </Style>
  50. <Style Selector="ToggleButton:checked">
  51. <Setter Property="Background" Value="Transparent" />
  52. </Style>
  53. </Border.Styles>
  54. <suki:GlassCard
  55. Name="border"
  56. Padding="{TemplateBinding Padding}"
  57. BorderBrush="{TemplateBinding BorderBrush}"
  58. BorderThickness="{TemplateBinding BorderThickness}"
  59. Classes="Discrete"
  60. CornerRadius="{TemplateBinding CornerRadius}">
  61. <suki:GlassCard.Transitions>
  62. <Transitions>
  63. <BrushTransition Property="BorderBrush" Duration="0:0:0.2" />
  64. </Transitions>
  65. </suki:GlassCard.Transitions>
  66. <Grid ColumnDefinitions="*,Auto">
  67. <Grid.Resources>
  68. <theme:BiggestItemConverter x:Key="BigItem" />
  69. </Grid.Resources>
  70. <TextBlock
  71. Name="PlaceholderTextBlock"
  72. Grid.Column="0"
  73. Margin="7,1,0,0"
  74. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  75. VerticalAlignment="Center"
  76. Foreground="{TemplateBinding PlaceholderForeground}"
  77. IsVisible="{TemplateBinding SelectionBoxItem,
  78. Converter={x:Static ObjectConverters.IsNull}}"
  79. Text="{TemplateBinding PlaceholderText}" />
  80. <ContentControl
  81. Margin="7,1,0,0"
  82. HorizontalContentAlignment="Left"
  83. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  84. Classes="ghost"
  85. Content="{TemplateBinding ItemsSource,
  86. Converter={StaticResource BigItem}}"
  87. ContentTemplate="{TemplateBinding ItemTemplate}"
  88. Foreground="Transparent" />
  89. <ContentControl
  90. Margin="7,1,0,0"
  91. HorizontalContentAlignment="Left"
  92. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  93. Content="{TemplateBinding SelectionBoxItem}"
  94. ContentTemplate="{TemplateBinding ItemTemplate}"
  95. Foreground="{DynamicResource SukiText}" />
  96. <ToggleButton
  97. Name="toggle"
  98. Grid.Column="1"
  99. Margin="10,0,0,0"
  100. Background="Transparent"
  101. BorderThickness="0"
  102. ClickMode="Press"
  103. CornerRadius="{DynamicResource SmallCornerRadius}"
  104. Focusable="False"
  105. IsChecked="{TemplateBinding IsDropDownOpen,
  106. Mode=TwoWay}">
  107. <Path
  108. Width="8"
  109. Height="4"
  110. HorizontalAlignment="Center"
  111. VerticalAlignment="Center"
  112. Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"
  113. Fill="{DynamicResource SukiText}"
  114. Stretch="Uniform" />
  115. </ToggleButton>
  116. <Popup
  117. Name="PART_Popup"
  118. MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
  119. MaxHeight="{TemplateBinding MaxDropDownHeight}"
  120. HorizontalOffset="-5"
  121. IsLightDismissEnabled="True"
  122. IsOpen="{TemplateBinding IsDropDownOpen,
  123. Mode=TwoWay}"
  124. PlacementTarget="{TemplateBinding}">
  125. <LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="50%, 0%">
  126. <Border Name="B1" Padding="5,10,5,5">
  127. <Panel>
  128. <Border
  129. Margin="10,-10,0,0"
  130. Background="{DynamicResource SukiCardBackground}"
  131. BorderBrush="{DynamicResource SukiMenuBorderBrush}"
  132. BorderThickness="1,1,1,1"
  133. BoxShadow="{DynamicResource SukiSmallPopupShadow}"
  134. CornerRadius="{DynamicResource SmallCornerRadius}">
  135. <Panel Background="{DynamicResource PopupGradientBrush}">
  136. <ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
  137. <ItemsPresenter
  138. Name="PART_ItemsPresenter"
  139. Margin="0,3,0,0"
  140. ItemsPanel="{TemplateBinding ItemsPanel}" />
  141. </ScrollViewer>
  142. </Panel>
  143. </Border>
  144. </Panel>
  145. </Border>
  146. </LayoutTransformControl>
  147. </Popup>
  148. </Grid>
  149. </suki:GlassCard>
  150. </Border>
  151. </ControlTemplate>
  152. </Setter>
  153. </Style>
  154. <Style Selector="ComboBox[IsDropDownOpen=true] /template/ LayoutTransformControl#PART_LayoutTransform">
  155. <Style.Resources>
  156. <theme:PlusNineConverter x:Key="NineConverter" />
  157. </Style.Resources>
  158. <Style.Animations>
  159. <Animation
  160. Easing="SineEaseOut"
  161. FillMode="Forward"
  162. Duration="0:0:0.3">
  163. <KeyFrame Cue="0%">
  164. <Setter Property="ScaleTransform.ScaleY" Value="0.92" />
  165. <Setter Property="ScaleTransform.ScaleX" Value="0.95" />
  166. <Setter Property="Opacity" Value="0" />
  167. </KeyFrame>
  168. <KeyFrame Cue="100%">
  169. <Setter Property="ScaleTransform.ScaleY" Value="1" />
  170. <Setter Property="ScaleTransform.ScaleX" Value="1" />
  171. <Setter Property="Opacity" Value="1" />
  172. </KeyFrame>
  173. </Animation>
  174. </Style.Animations>
  175. </Style>
  176. <Style Selector="ComboBox[IsDropDownOpen=false] /template/ LayoutTransformControl#PART_LayoutTransform">
  177. <Style.Resources>
  178. <theme:PlusNineConverter x:Key="NineConverter" />
  179. </Style.Resources>
  180. <Style.Animations>
  181. <Animation
  182. Easing="CircularEaseOut"
  183. FillMode="Forward"
  184. Duration="0:0:0.3">
  185. <KeyFrame Cue="0%">
  186. <Setter Property="ScaleTransform.ScaleY" Value="1" />
  187. <Setter Property="ScaleTransform.ScaleX" Value="1" />
  188. <Setter Property="Opacity" Value="1" />
  189. </KeyFrame>
  190. <KeyFrame Cue="100%">
  191. <Setter Property="ScaleTransform.ScaleY" Value="0.9" />
  192. <Setter Property="ScaleTransform.ScaleX" Value="0.9" />
  193. <Setter Property="Opacity" Value="0" />
  194. </KeyFrame>
  195. </Animation>
  196. </Style.Animations>
  197. </Style>
  198. <Style Selector="ComboBox:pointerover /template/ suki|GlassCard#border">
  199. <Setter Property="BorderBrush" Value="{DynamicResource SukiLightBorderBrush}" />
  200. </Style>
  201. <Style Selector="ComboBox:disabled /template/ suki|GlassCard#border">
  202. <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
  203. </Style>
  204. </Styles>