CutOverControl.xaml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <UserControl x:Class="Muchinfo.WPF.Controls.MarQuees.CutOverControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. x:Name="CutOver"
  8. mc:Ignorable="d">
  9. <UserControl.Resources>
  10. <Style x:Key="CutOverListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
  11. <EventSetter Event="MouseLeftButtonUp"
  12. HandledEventsToo="True"
  13. Handler="EventSetter_OnHandler" />
  14. <Setter Property="Background" Value="Transparent" />
  15. <Setter Property="HorizontalContentAlignment" Value="Left" />
  16. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  17. <Setter Property="Margin" Value="0,1,10,1" />
  18. <Setter Property="Template">
  19. <Setter.Value>
  20. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  21. <Border x:Name="Bd"
  22. Background="{TemplateBinding Background}"
  23. BorderBrush="{TemplateBinding BorderBrush}"
  24. BorderThickness="{TemplateBinding BorderThickness}"
  25. Padding="{TemplateBinding Padding}"
  26. SnapsToDevicePixels="true">
  27. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  28. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  29. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  30. </Border>
  31. <ControlTemplate.Triggers>
  32. <Trigger Property="IsMouseOver" Value="true">
  33. <Setter Property="BorderThickness" Value="0,0,0,1" />
  34. <Setter Property="Foreground" Value="PaleTurquoise" />
  35. <Setter Property="BorderBrush" Value="PaleTurquoise" />
  36. <Setter Property="Cursor" Value="Hand" />
  37. </Trigger>
  38. </ControlTemplate.Triggers>
  39. <!--
  40. <MultiTrigger>
  41. <MultiTrigger.Conditions>
  42. <Condition Property="IsSelected" Value="true"/>
  43. <Condition Property="Selector.IsSelectionActive" Value="false"/>
  44. </MultiTrigger.Conditions>
  45. <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
  46. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  47. </MultiTrigger>
  48. <Trigger Property="IsEnabled" Value="false">
  49. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  50. </Trigger>
  51. </ControlTemplate.Triggers>
  52. -->
  53. </ControlTemplate>
  54. </Setter.Value>
  55. </Setter>
  56. </Style>
  57. <Style x:Key="CutOverListBoxStyle1" TargetType="{x:Type ListBox}">
  58. <Setter Property="Background" Value="Transparent" />
  59. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
  60. <Setter Property="BorderBrush" Value="{x:Static Themes:ClassicBorderDecorator.ClassicBorderBrush}" />
  61. <Setter Property="BorderThickness" Value="0" />
  62. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
  63. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
  64. <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
  65. <Setter Property="VerticalContentAlignment" Value="Center" />
  66. <Setter Property="ItemsPanel">
  67. <Setter.Value>
  68. <ItemsPanelTemplate>
  69. <WrapPanel ItemWidth="Auto" Orientation="Horizontal" />
  70. </ItemsPanelTemplate>
  71. </Setter.Value>
  72. </Setter>
  73. <Setter Property="Template">
  74. <Setter.Value>
  75. <ControlTemplate TargetType="{x:Type ListBox}">
  76. <Themes:ClassicBorderDecorator x:Name="Bd"
  77. Background="{TemplateBinding Background}"
  78. BorderBrush="{TemplateBinding BorderBrush}"
  79. BorderStyle="Sunken"
  80. BorderThickness="{TemplateBinding BorderThickness}"
  81. SnapsToDevicePixels="true">
  82. <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
  83. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  84. </ScrollViewer>
  85. </Themes:ClassicBorderDecorator>
  86. <ControlTemplate.Triggers>
  87. <Trigger Property="IsEnabled" Value="false">
  88. <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
  89. </Trigger>
  90. <Trigger Property="IsGrouping" Value="true">
  91. <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
  92. </Trigger>
  93. </ControlTemplate.Triggers>
  94. </ControlTemplate>
  95. </Setter.Value>
  96. </Setter>
  97. </Style>
  98. </UserControl.Resources>
  99. <Grid>
  100. <ListBox x:Name="ContentListBox"
  101. Width="{Binding ActualWidth,
  102. ElementName=CutOver,
  103. Mode=OneWay}"
  104. BorderBrush="{Binding BorderBrush,
  105. ElementName=CutOver}"
  106. BorderThickness="{Binding BorderThickness,
  107. ElementName=CutOver}"
  108. FontSize="{Binding FontSize,
  109. ElementName=CutOver}"
  110. Foreground="{Binding Foreground,
  111. ElementName=CutOver}"
  112. ItemContainerStyle="{DynamicResource CutOverListBoxItemStyle}"
  113. ItemTemplate="{Binding ItemTemplate,
  114. ElementName=CutOver}"
  115. ItemsSource="{Binding ItemsSource,
  116. ElementName=CutOver}"
  117. MouseEnter="UIElement_OnMouseEnter"
  118. MouseLeave="UIElement_OnMouseLeave"
  119. Style="{DynamicResource CutOverListBoxStyle1}" />
  120. </Grid>
  121. </UserControl>