ListBoxStyles.xaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <Styles xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:theme="clr-namespace:SukiUI.Theme">
  4. <Design.PreviewWith>
  5. <Border Padding="20" Background="{DynamicResource SukiBackground}">
  6. <StackPanel Orientation="Horizontal">
  7. <ListBox Width="150">
  8. <ListBoxItem>Test</ListBoxItem>
  9. <ListBoxItem>Test</ListBoxItem>
  10. <ListBoxItem>Test</ListBoxItem>
  11. <ListBoxItem>Test</ListBoxItem>
  12. </ListBox>
  13. <ListBox Width="150" Classes="WithoutCheck">
  14. <ListBoxItem>Test</ListBoxItem>
  15. <ListBoxItem>Test</ListBoxItem>
  16. <ListBoxItem>Test</ListBoxItem>
  17. <ListBoxItem>Test</ListBoxItem>
  18. </ListBox>
  19. <ListBox Width="150" Classes="Stack">
  20. <ListBoxItem>Test</ListBoxItem>
  21. <ListBoxItem>Test</ListBoxItem>
  22. <ListBoxItem>Test</ListBoxItem>
  23. <ListBoxItem>Test</ListBoxItem>
  24. </ListBox>
  25. </StackPanel>
  26. </Border>
  27. </Design.PreviewWith>
  28. <Style Selector="ListBox">
  29. <Setter Property="TextBlock.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
  30. <Setter Property="Background" Value="Transparent" />
  31. <Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
  32. <Setter Property="BorderThickness" Value="{DynamicResource ListBoxBorderThemeThickness}" />
  33. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
  34. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  35. <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
  36. <Setter Property="Template">
  37. <ControlTemplate>
  38. <Border Name="border"
  39. Background="{TemplateBinding Background}"
  40. BorderBrush="{TemplateBinding BorderBrush}"
  41. BorderThickness="0"
  42. ClipToBounds="{TemplateBinding ClipToBounds}"
  43. CornerRadius="{TemplateBinding CornerRadius}">
  44. <Border.Resources>
  45. <theme:BiggestItemListBoxConverter x:Key="BiggestListItem" />
  46. </Border.Resources>
  47. <Panel>
  48. <ListBoxItem Margin="0,0,32,0"
  49. Content="{TemplateBinding ItemsSource,
  50. Converter={StaticResource BiggestListItem}}"
  51. Opacity="0" />
  52. <ScrollViewer Name="PART_ScrollViewer"
  53. HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
  54. VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
  55. <ItemsPresenter Name="PART_ItemsPresenter"
  56. Margin="{TemplateBinding Padding}"
  57. ItemsPanel="{TemplateBinding ItemsPanel}" />
  58. </ScrollViewer>
  59. </Panel>
  60. </Border>
  61. </ControlTemplate>
  62. </Setter>
  63. </Style>
  64. <Style Selector="ListBox.WithoutCheck ListBoxItem /template/ PathIcon#CheckSelected">
  65. <Setter Property="IsVisible" Value="False" />
  66. </Style>
  67. <Style Selector="ListBox.Stack">
  68. <Setter Property="TextBlock.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
  69. <Setter Property="Background" Value="Transparent" />
  70. <Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
  71. <Setter Property="BorderThickness" Value="{DynamicResource ListBoxBorderThemeThickness}" />
  72. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
  73. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  74. <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
  75. <Setter Property="Template">
  76. <ControlTemplate>
  77. <Border Name="border"
  78. Background="{TemplateBinding Background}"
  79. BorderBrush="{TemplateBinding BorderBrush}"
  80. BorderThickness="0"
  81. ClipToBounds="{TemplateBinding ClipToBounds}"
  82. CornerRadius="{TemplateBinding CornerRadius}">
  83. <Border.Resources>
  84. <theme:BiggestItemListBoxConverter x:Key="BiggestListItem" />
  85. </Border.Resources>
  86. <Panel>
  87. <ListBoxItem Margin="0,0,32,0"
  88. Content="{TemplateBinding ItemsSource,
  89. Converter={StaticResource BiggestListItem}}"
  90. Opacity="0" />
  91. <ScrollViewer Name="PART_ScrollViewer"
  92. Classes="Stack"
  93. HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
  94. VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
  95. <ItemsPresenter Name="PART_ItemsPresenter"
  96. Margin="{TemplateBinding Padding}"
  97. ItemsPanel="{TemplateBinding ItemsPanel}" />
  98. </ScrollViewer>
  99. </Panel>
  100. </Border>
  101. </ControlTemplate>
  102. </Setter>
  103. </Style>
  104. </Styles>