ListBoxItemStyle.axaml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <Styles xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:content="clr-namespace:SukiUI.Content">
  4. <Design.PreviewWith>
  5. <Border Padding="0">
  6. <ListBox>
  7. <ListBoxItem>Disabled</ListBoxItem>
  8. <ListBoxItem>
  9. Test
  10. </ListBoxItem>
  11. <ListBoxItem>Test</ListBoxItem>
  12. </ListBox>
  13. </Border>
  14. </Design.PreviewWith>
  15. <Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
  16. <Setter Property="Background" Value="Transparent" />
  17. </Style>
  18. <Style Selector="ListBoxItem:selected &gt; TextBlock">
  19. <Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}" />
  20. </Style>
  21. <Style Selector="ListBoxItem">
  22. <Setter Property="Background" Value="Transparent" />
  23. <Setter Property="Padding" Value="4,2" />
  24. <Setter Property="Template">
  25. <ControlTemplate>
  26. <Border Name="BorderBasicStyle"
  27. Margin="0,0,0,0"
  28. Padding="8,4"
  29. CornerRadius="10">
  30. <DockPanel>
  31. <PathIcon Name="CheckSelected"
  32. Width="17"
  33. Height="17"
  34. Margin="8,0,0,0"
  35. Data="{x:Static content:Icons.CircleCheck}"
  36. DockPanel.Dock="Right"
  37. Foreground="{DynamicResource SukiPrimaryColor}">
  38. <PathIcon.Transitions>
  39. <Transitions>
  40. <DoubleTransition Property="Opacity" Duration="0:0:0.2" />
  41. </Transitions>
  42. </PathIcon.Transitions>
  43. </PathIcon>
  44. <ContentPresenter Name="PART_ContentPresenter"
  45. Margin="0,0,0,0"
  46. Padding="{TemplateBinding Padding}"
  47. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  48. Background="Transparent"
  49. BorderBrush="Transparent"
  50. BorderThickness="{TemplateBinding BorderThickness}"
  51. Content="{TemplateBinding Content}"
  52. ContentTemplate="{TemplateBinding ContentTemplate}"
  53. CornerRadius="{TemplateBinding CornerRadius}" />
  54. </DockPanel>
  55. </Border>
  56. </ControlTemplate>
  57. </Setter>
  58. </Style>
  59. <Style Selector="ListBoxItem:selected /template/ PathIcon#CheckSelected">
  60. <Setter Property="Opacity" Value="1" />
  61. </Style>
  62. <Style Selector="ListBoxItem /template/ PathIcon#CheckSelected">
  63. <Setter Property="Opacity" Value="0" />
  64. </Style>
  65. <Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
  66. <Setter Property="Background" Value="Transparent" />
  67. </Style>
  68. <Style Selector="ListBoxItem:selected /template/ Border#BorderBasicStyle">
  69. <Setter Property="Background" Value="{DynamicResource SukiPrimaryColor10}" />
  70. </Style>
  71. <Style Selector="ListBoxItem:pointerover /template/ Border#BorderBasicStyle">
  72. <Setter Property="Background" Value="{DynamicResource SukiPrimaryColor5}" />
  73. </Style>
  74. <!-- <Style Selector="ListBoxItem.WithCheck">
  75. <Setter Property="Background" Value="Transparent" />
  76. <Setter Property="Template">
  77. <ControlTemplate>
  78. <StackPanel Orientation="Horizontal">
  79. <CheckBox Margin="2" IsEnabled="False">
  80. <CheckBox.RenderTransform>
  81. <ScaleTransform ScaleX="1.2" ScaleY="1.2" />
  82. </CheckBox.RenderTransform>
  83. </CheckBox>
  84. <ContentPresenter Name="PART_ContentPresenter"
  85. Margin="-8,0,0,0"
  86. Padding="{TemplateBinding Padding}"
  87. VerticalAlignment="Center"
  88. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  89. VerticalContentAlignment="Center"
  90. Background="Transparent"
  91. BorderBrush="Transparent"
  92. BorderThickness="{TemplateBinding BorderThickness}"
  93. Content="{TemplateBinding Content}"
  94. ContentTemplate="{TemplateBinding ContentTemplate}"
  95. CornerRadius="{TemplateBinding CornerRadius}" />
  96. </StackPanel>
  97. </ControlTemplate>
  98. </Setter>
  99. </Style>
  100. <Style Selector="ListBoxItem.WithCheck:selected /template/ ContentPresenter#PART_ContentPresenter">
  101. <Setter Property="Background" Value="Transparent" />
  102. </Style>
  103. <Style Selector="ListBoxItem.WithCheck:pointerover /template/ ContentPresenter#PART_ContentPresenter">
  104. <Setter Property="Background" Value="Transparent" />
  105. </Style>
  106. <Style Selector="ListBoxItem.WithCheck:selected /template/ ContentPresenter#PART_ContentPresenter">
  107. <Setter Property="Background" Value="Transparent" />
  108. </Style>
  109. <Style Selector="ListBoxItem.WithCheck">
  110. <Setter Property="Background" Value="Transparent" />
  111. <Setter Property="BorderThickness" Value="10 0 0 0" />
  112. <Setter Property="BorderBrush" Value="{DynamicResource ThemeBackgroundBrush}" />
  113. <Setter Property="Padding" Value="10 0" />
  114. <Setter Property="Margin" Value="0 5" />
  115. </Style>
  116. <Style Selector="ListBoxItem.WithCheck:selected /template/ CheckBox">
  117. <Setter Property="IsChecked" Value="True" />
  118. </Style>
  119. <Style Selector="ListBoxItem.WithCheck /template/ CheckBox">
  120. <Setter Property="IsChecked" Value="False" />
  121. </Style>-->
  122. <Style Selector=" ListBox.Void ListBoxItem">
  123. <Setter Property="Background" Value="Transparent" />
  124. <Setter Property="Padding" Value="4,2" />
  125. <Setter Property="Template">
  126. <ControlTemplate>
  127. <ContentPresenter Name="PART_ContentPresenter"
  128. Margin="0,0,0,0"
  129. Padding="{TemplateBinding Padding}"
  130. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  131. Background="Transparent"
  132. BorderBrush="Transparent"
  133. BorderThickness="{TemplateBinding BorderThickness}"
  134. Content="{TemplateBinding Content}"
  135. ContentTemplate="{TemplateBinding ContentTemplate}"
  136. CornerRadius="{TemplateBinding CornerRadius}" />
  137. </ControlTemplate>
  138. </Setter>
  139. </Style>
  140. <Style Selector=" ListBox.Void ListBoxItem">
  141. <Setter Property="Background" Value="Transparent" />
  142. <Setter Property="Padding" Value="4,2" />
  143. <Setter Property="Template">
  144. <ControlTemplate>
  145. <ContentPresenter Name="PART_ContentPresenter"
  146. Margin="0,0,0,0"
  147. Padding="{TemplateBinding Padding}"
  148. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  149. Background="Transparent"
  150. BorderBrush="Transparent"
  151. BorderThickness="{TemplateBinding BorderThickness}"
  152. Content="{TemplateBinding Content}"
  153. ContentTemplate="{TemplateBinding ContentTemplate}"
  154. CornerRadius="{TemplateBinding CornerRadius}" />
  155. </ControlTemplate>
  156. </Setter>
  157. </Style>
  158. </Styles>