25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

251 satır
16 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl"
  4. xmlns:converter="clr-namespace:BPA.UIControl.Converters">
  5. <ResourceDictionary.MergedDictionaries>
  6. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Resources/Default.xaml" />
  7. </ResourceDictionary.MergedDictionaries>
  8. <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
  9. <Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}" />
  10. <Setter Property="Cursor" Value="Hand" />
  11. <Setter Property="Focusable" Value="False" />
  12. <Setter Property="Template">
  13. <Setter.Value>
  14. <ControlTemplate TargetType="{x:Type ToggleButton}">
  15. <Border Background="Transparent">
  16. <bpa:Icon x:Name="ExpandPath"
  17. Foreground="{TemplateBinding Foreground}"
  18. RenderTransformOrigin="0.5 0.5"
  19. Type="{Binding Path=(bpa:TreeViewHelper.ExpandIconType), RelativeSource={RelativeSource AncestorType=TreeView}}">
  20. <bpa:Icon.RenderTransform>
  21. <RotateTransform x:Name="transform" Angle="0" />
  22. </bpa:Icon.RenderTransform>
  23. </bpa:Icon>
  24. </Border>
  25. <ControlTemplate.Triggers>
  26. <Trigger Property="IsChecked" Value="True">
  27. <Trigger.EnterActions>
  28. <BeginStoryboard>
  29. <Storyboard>
  30. <DoubleAnimation Storyboard.TargetName="transform"
  31. Storyboard.TargetProperty="Angle"
  32. To="45"
  33. Duration="0:0:0.15">
  34. <DoubleAnimation.EasingFunction>
  35. <CubicEase EasingMode="EaseOut" />
  36. </DoubleAnimation.EasingFunction>
  37. </DoubleAnimation>
  38. </Storyboard>
  39. </BeginStoryboard>
  40. </Trigger.EnterActions>
  41. <Trigger.ExitActions>
  42. <BeginStoryboard>
  43. <Storyboard>
  44. <DoubleAnimation Storyboard.TargetName="transform"
  45. Storyboard.TargetProperty="Angle"
  46. To="0"
  47. Duration="0:0:0.15">
  48. <DoubleAnimation.EasingFunction>
  49. <CubicEase EasingMode="EaseOut" />
  50. </DoubleAnimation.EasingFunction>
  51. </DoubleAnimation>
  52. </Storyboard>
  53. </BeginStoryboard>
  54. </Trigger.ExitActions>
  55. <Setter TargetName="ExpandPath" Property="Foreground" Value="{Binding Path=(bpa:TreeViewHelper.IconFocusedBrush), RelativeSource={RelativeSource AncestorType=TreeView}}" />
  56. </Trigger>
  57. <Trigger Property="IsMouseOver" Value="True">
  58. <Setter TargetName="ExpandPath" Property="Foreground" Value="{Binding Path=(bpa:TreeViewHelper.IconFocusedBrush), RelativeSource={RelativeSource AncestorType=TreeView}}" />
  59. </Trigger>
  60. </ControlTemplate.Triggers>
  61. </ControlTemplate>
  62. </Setter.Value>
  63. </Setter>
  64. </Style>
  65. <Style x:Key="RubyerTreeViewItem" TargetType="{x:Type TreeViewItem}">
  66. <Setter Property="Background" Value="Transparent" />
  67. <Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}" />
  68. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  69. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
  70. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
  71. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
  72. <Setter Property="Padding" Value="{Binding Path=(bpa:ItemsControlHelper.ItemPadding), RelativeSource={RelativeSource AncestorType=TreeView}}" />
  73. <Setter Property="Margin" Value="{Binding Path=(bpa:ItemsControlHelper.ItemMargin), RelativeSource={RelativeSource AncestorType=TreeView}}" />
  74. <Setter Property="Template">
  75. <Setter.Value>
  76. <ControlTemplate TargetType="{x:Type TreeViewItem}">
  77. <Grid x:Name="root">
  78. <Grid.ColumnDefinitions>
  79. <ColumnDefinition Width="Auto" />
  80. <ColumnDefinition Width="*" />
  81. </Grid.ColumnDefinitions>
  82. <Grid.RowDefinitions>
  83. <RowDefinition Height="Auto" />
  84. <RowDefinition />
  85. </Grid.RowDefinitions>
  86. <ToggleButton x:Name="Expander"
  87. Style="{StaticResource ExpandCollapseToggleStyle}"
  88. ClickMode="Press"
  89. IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" />
  90. <bpa:ControlMask Grid.Column="1"
  91. Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=TreeView}}"
  92. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=TreeView}}"
  93. IsActive="{TemplateBinding IsSelected}"
  94. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource AncestorType=TreeView}}" />
  95. <Border x:Name="Bd"
  96. Grid.Column="1"
  97. Padding="{TemplateBinding Padding}"
  98. Background="{TemplateBinding Background}"
  99. BorderBrush="{TemplateBinding BorderBrush}"
  100. BorderThickness="{TemplateBinding BorderThickness}"
  101. SnapsToDevicePixels="true">
  102. <ContentPresenter x:Name="PART_Header"
  103. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  104. ContentSource="Header"
  105. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  106. </Border>
  107. <bpa:Transition Grid.Row="1"
  108. Grid.Column="1"
  109. IsShow="{TemplateBinding IsExpanded}"
  110. Type="CollapseUp">
  111. <ItemsPresenter x:Name="ItemsHost"
  112. VerticalAlignment="Top"
  113. Opacity="0"
  114. Visibility="Collapsed" />
  115. </bpa:Transition>
  116. </Grid>
  117. <ControlTemplate.Triggers>
  118. <Trigger Property="IsExpanded" Value="True">
  119. <Trigger.EnterActions>
  120. <BeginStoryboard>
  121. <Storyboard>
  122. <DoubleAnimation Storyboard.TargetName="ItemsHost"
  123. Storyboard.TargetProperty="Opacity"
  124. To="1"
  125. Duration="0:0:0.3">
  126. <DoubleAnimation.EasingFunction>
  127. <CubicEase EasingMode="EaseOut" />
  128. </DoubleAnimation.EasingFunction>
  129. </DoubleAnimation>
  130. <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="Visibility">
  131. <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
  132. </ObjectAnimationUsingKeyFrames>
  133. </Storyboard>
  134. </BeginStoryboard>
  135. </Trigger.EnterActions>
  136. <Trigger.ExitActions>
  137. <BeginStoryboard>
  138. <Storyboard>
  139. <DoubleAnimation Storyboard.TargetName="ItemsHost"
  140. Storyboard.TargetProperty="Opacity"
  141. To="0"
  142. Duration="0:0:0.3">
  143. <DoubleAnimation.EasingFunction>
  144. <CubicEase EasingMode="EaseOut" />
  145. </DoubleAnimation.EasingFunction>
  146. </DoubleAnimation>
  147. <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="Visibility">
  148. <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Collapsed}" />
  149. </ObjectAnimationUsingKeyFrames>
  150. </Storyboard>
  151. </BeginStoryboard>
  152. </Trigger.ExitActions>
  153. </Trigger>
  154. <Trigger Property="HasItems" Value="false">
  155. <Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
  156. </Trigger>
  157. <Trigger Property="IsEnabled" Value="false">
  158. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  159. </Trigger>
  160. <Trigger Property="IsSelected" Value="True">
  161. <Setter Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource AncestorType=TreeView}}" />
  162. </Trigger>
  163. </ControlTemplate.Triggers>
  164. </ControlTemplate>
  165. </Setter.Value>
  166. </Setter>
  167. <Style.Triggers>
  168. <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
  169. <Setter Property="ItemsPanel">
  170. <Setter.Value>
  171. <ItemsPanelTemplate>
  172. <VirtualizingStackPanel />
  173. </ItemsPanelTemplate>
  174. </Setter.Value>
  175. </Setter>
  176. </Trigger>
  177. </Style.Triggers>
  178. </Style>
  179. <Style x:Key="RubyerTreeView" TargetType="{x:Type TreeView}">
  180. <Setter Property="Background" Value="Transparent" />
  181. <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
  182. <Setter Property="BorderThickness" Value="0" />
  183. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  184. <Setter Property="VerticalContentAlignment" Value="Center" />
  185. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  186. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
  187. <Setter Property="ScrollViewer.PanningMode" Value="Both" />
  188. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  189. <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  190. <Setter Property="SnapsToDevicePixels" Value="True" />
  191. <Setter Property="ItemContainerStyle" Value="{StaticResource RubyerTreeViewItem}" />
  192. <Setter Property="bpa:ControlHelper.CornerRadius" Value="0" />
  193. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Mask}" />
  194. <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource DefaultForeground}" />
  195. <Setter Property="bpa:ControlHelper.CornerRadius" Value="0" />
  196. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.6" />
  197. <Setter Property="bpa:ItemsControlHelper.ItemMargin" Value="0" />
  198. <Setter Property="bpa:ItemsControlHelper.ItemPadding" Value="5" />
  199. <Setter Property="bpa:TreeViewHelper.IconFocusedBrush" Value="{DynamicResource Primary}" />
  200. <Setter Property="bpa:TreeViewHelper.RightClickToSelected" Value="True" />
  201. <Setter Property="bpa:TreeViewHelper.IsBindable" Value="True" />
  202. <Setter Property="Template">
  203. <Setter.Value>
  204. <ControlTemplate TargetType="{x:Type TreeView}">
  205. <Border x:Name="Bd"
  206. BorderBrush="{TemplateBinding BorderBrush}"
  207. BorderThickness="{TemplateBinding BorderThickness}"
  208. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  209. <ScrollViewer x:Name="_tv_scrollviewer_"
  210. Padding="{TemplateBinding Padding}"
  211. Background="{TemplateBinding Background}"
  212. CanContentScroll="false"
  213. Focusable="false"
  214. HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
  215. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  216. VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
  217. <ItemsPresenter x:Name="items" OverridesDefaultStyle="True" />
  218. </ScrollViewer>
  219. </Border>
  220. <ControlTemplate.Triggers>
  221. <Trigger Property="IsEnabled" Value="False">
  222. <Setter TargetName="Bd" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  223. </Trigger>
  224. <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="True">
  225. <Setter TargetName="_tv_scrollviewer_" Property="CanContentScroll" Value="True" />
  226. </Trigger>
  227. </ControlTemplate.Triggers>
  228. </ControlTemplate>
  229. </Setter.Value>
  230. </Setter>
  231. <Style.Triggers>
  232. <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="True">
  233. <Setter Property="ItemsPanel">
  234. <Setter.Value>
  235. <ItemsPanelTemplate>
  236. <VirtualizingStackPanel />
  237. </ItemsPanelTemplate>
  238. </Setter.Value>
  239. </Setter>
  240. </Trigger>
  241. </Style.Triggers>
  242. </Style>
  243. </ResourceDictionary>