QuickTimeSpan.xaml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <UserControl x:Class="MuchInfo.Chart.WPF.Controls.QuickTimeSpan.QuickTimeSpan"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:cv="clr-namespace:MuchInfo.Chart.WPF.Converter">
  7. <UserControl.Resources>
  8. <!--ListBox Style-->
  9. <Style TargetType="ListBox">
  10. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  11. <Setter Property="Background" Value="{x:Null}" />
  12. <Setter Property="BorderBrush" Value="{x:Null}" />
  13. <Setter Property="Focusable" Value="False" />
  14. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
  15. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
  16. </Style>
  17. <!--ListBoxItem Style-->
  18. <Style TargetType="ListBoxItem">
  19. <Style.Resources>
  20. <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
  21. <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
  22. <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
  23. <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" />
  24. </Style.Resources>
  25. </Style>
  26. <!--ListBoxTimeSpanButtonDataTemplate-->
  27. <DataTemplate x:Key="ListBoxTimeSpanButtonDataTemplate">
  28. <DataTemplate.Resources>
  29. <cv:QuikTimeSpanConverter x:Key="QuikTimeSpanConverter" />
  30. </DataTemplate.Resources>
  31. <Border MinWidth="25" Background="LightCyan" BorderBrush="Gray" BorderThickness="1" CornerRadius="3"
  32. Padding="5,2">
  33. <TextBlock Text="{Binding Converter={StaticResource QuikTimeSpanConverter}, Mode=OneWay}"
  34. HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0" />
  35. </Border>
  36. <DataTemplate.Triggers>
  37. <DataTrigger
  38. Binding="{Binding Path=IsSelected,Mode=TwoWay,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBoxItem}}}"
  39. Value="true">
  40. <Setter Property="Opacity" Value="1" />
  41. </DataTrigger>
  42. <DataTrigger
  43. Binding="{Binding Path=IsSelected,Mode=TwoWay,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBoxItem}}}"
  44. Value="false">
  45. <Setter Property="Opacity" Value="0.4" />
  46. </DataTrigger>
  47. </DataTemplate.Triggers>
  48. </DataTemplate>
  49. <!--ListBoxTimeSpanButtonItemsPanelTemplate-->
  50. <ItemsPanelTemplate x:Key="ListBoxTimeSpanButtonItemsPanelTemplate">
  51. <WrapPanel Orientation="Horizontal" IsItemsHost="True" ScrollViewer.VerticalScrollBarVisibility="Disabled"
  52. HorizontalAlignment="Center" />
  53. </ItemsPanelTemplate>
  54. </UserControl.Resources>
  55. <Grid>
  56. <ListBox x:Name="qtsListBox" ItemsSource="{Binding CycleItems,Mode=TwoWay}"
  57. SelectedItem="{Binding CycleType,Mode=TwoWay}"
  58. ItemTemplate="{DynamicResource ListBoxTimeSpanButtonDataTemplate}" Focusable="False"
  59. ItemsPanel="{DynamicResource ListBoxTimeSpanButtonItemsPanelTemplate}" HorizontalAlignment="Center"
  60. VerticalAlignment="Center" Margin="10,0" PreviewKeyDown="qtsListBox_PreviewKeyDown" />
  61. </Grid>
  62. </UserControl>