ComboBoxStyle.xaml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <Style TargetType="ComboBox">
  4. <Setter Property="FontFamily" Value="Arial,SimSun" />
  5. <Setter Property="Background" Value="#FFDCF7F6"></Setter>
  6. </Style>
  7. <Style TargetType="ComboBox" x:Key="EventComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
  8. <Setter Property="Height" Value="28" />
  9. <Setter Property="FontSize" Value="14" />
  10. </Style>
  11. <Style TargetType="ToggleButton" x:Key="ComboxStyleBtn">
  12. <Setter Property="Template">
  13. <Setter.Value>
  14. <ControlTemplate>
  15. <!--下拉按钮内部背景色-->
  16. <Border x:Name="Back" Background="#56b6e6" BorderThickness="1" BorderBrush="Transparent">
  17. <!--下拉按钮内边框-->
  18. <Path Name="PathFill" Fill="#03ffea" Width="10" Height="6" StrokeThickness="0" Data="M5,0 L10,10 L0,10 z" RenderTransformOrigin="0.5,0.5" Stretch="Fill">
  19. <Path.RenderTransform>
  20. <TransformGroup>
  21. <ScaleTransform/>
  22. <SkewTransform/>
  23. <RotateTransform Angle="180"/>
  24. <TranslateTransform/>
  25. </TransformGroup>
  26. </Path.RenderTransform>
  27. </Path>
  28. </Border>
  29. <ControlTemplate.Triggers>
  30. <Trigger Property="IsMouseOver" Value="True">
  31. <Setter TargetName="PathFill" Property="Fill" Value="White"></Setter>
  32. </Trigger>
  33. </ControlTemplate.Triggers>
  34. </ControlTemplate>
  35. </Setter.Value>
  36. </Setter>
  37. </Style>
  38. <Style TargetType="ToggleButton" x:Key="ComboxStyleBtnLabel">
  39. <Setter Property="Template">
  40. <Setter.Value>
  41. <ControlTemplate>
  42. <Label Background="{TemplateBinding Background}" VerticalAlignment="Stretch" Grid.Column="0" Foreground="{TemplateBinding Foreground}" BorderThickness="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Margin="0" ></Label>
  43. </ControlTemplate>
  44. </Setter.Value>
  45. </Setter>
  46. </Style>
  47. <Style TargetType="ComboBox" x:Key="TopFrameComboBoxStyle">
  48. <Setter Property="ItemTemplate">
  49. <Setter.Value>
  50. <DataTemplate>
  51. <ContentControl>
  52. <ContentControl.Style>
  53. <Style TargetType="ContentControl">
  54. <Setter Property="Background" Value="{StaticResource MessagesInformationBackgroundBrush}"/>
  55. <Style.Triggers>
  56. <DataTrigger Binding="{Binding Category}" Value="Error">
  57. <Setter Property="Foreground" Value="{StaticResource MessagesErrorForegroundBrush}"/>
  58. </DataTrigger>
  59. <DataTrigger Binding="{Binding Category}" Value="Warning">
  60. <Setter Property="Foreground" Value="{StaticResource MessagesWarningForegroundBrush}"/>
  61. </DataTrigger>
  62. <DataTrigger Binding="{Binding Category}" Value="Information">
  63. <Setter Property="Foreground" Value="{StaticResource MessagesInformationForegroundBrush}"/>
  64. </DataTrigger>
  65. </Style.Triggers>
  66. </Style>
  67. </ContentControl.Style>
  68. <Grid>
  69. <Grid.ColumnDefinitions>
  70. <ColumnDefinition Width="80"/>
  71. <ColumnDefinition Width="120"/>
  72. <ColumnDefinition Width="80"/>
  73. <ColumnDefinition Width="*"/>
  74. </Grid.ColumnDefinitions>
  75. <TextBlock Grid.Column="0" Text="{Binding UtcTimestamp, Converter={StaticResource UtcTimeToTextConverter}, ConverterParameter=HH:mm:ss.fff}" />
  76. <TextBlock Grid.Column="1" Text="{Binding Source}" Margin="8,0,0,0" />
  77. <TextBlock Grid.Column="2" Text="{Binding Type}" Margin="8,0,0,0"/>
  78. <TextBlock Grid.Column="3" Text="{Binding Message}" Margin="8,0,0,0"/>
  79. </Grid>
  80. </ContentControl>
  81. </DataTemplate>
  82. </Setter.Value>
  83. </Setter>
  84. </Style>
  85. <Style TargetType="ComboBox" x:Key="TopPanelComboBoxStyle">
  86. <Setter Property="ItemContainerStyle">
  87. <Setter.Value>
  88. <!--ComBoxItem-->
  89. <Style TargetType="ComboBoxItem">
  90. <Setter Property="MinHeight" Value="22"></Setter>
  91. <Setter Property="MinWidth" Value="60"></Setter>
  92. <Setter Property="Template">
  93. <Setter.Value>
  94. <ControlTemplate TargetType="ComboBoxItem">
  95. <Border Name="Back" Background="{TemplateBinding Background}" >
  96. <ContentPresenter ContentSource="{Binding Source}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" ></ContentPresenter>
  97. </Border>
  98. </ControlTemplate>
  99. </Setter.Value>
  100. </Setter>
  101. </Style>
  102. </Setter.Value>
  103. </Setter>
  104. <Setter Property="Template">
  105. <Setter.Value>
  106. <ControlTemplate TargetType="ComboBox">
  107. <Grid>
  108. <Grid.ColumnDefinitions>
  109. <ColumnDefinition Width="0.7*"/>
  110. <ColumnDefinition Width="0.3*" MaxWidth="30"/>
  111. </Grid.ColumnDefinitions>
  112. <!--文字区域背景和边线样式-->
  113. <Border Grid.Column="0" BorderThickness="1" BorderBrush="Gray" CornerRadius="1,0,0,1" >
  114. <Label Background="{TemplateBinding Background}" VerticalAlignment="Stretch" Grid.Column="0" Foreground="{TemplateBinding Foreground}" BorderThickness="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Content="{TemplateBinding Text}" Margin="0" ></Label>
  115. <!--<ToggleButton BorderThickness="0" BorderBrush="Gray" Style="{StaticResource ComboxStyleBtnLabel}" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"></ToggleButton>-->
  116. </Border>
  117. <!--右侧下拉button设置-->
  118. <Border Grid.Column="1" BorderThickness="0,1,1,1" BorderBrush="Gray" CornerRadius="0,1,1,0">
  119. <ToggleButton BorderThickness="3" BorderBrush="Gray" Style="{StaticResource ComboxStyleBtn}" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"></ToggleButton>
  120. </Border>
  121. <!--弹出popup整体设置-->
  122. <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide" >
  123. <!--弹出popup边框-->
  124. <Border CornerRadius="1" BorderBrush="Gray" BorderThickness="1,0,1,1" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
  125. <Border.Effect>
  126. <DropShadowEffect Color="LightGray" BlurRadius="2" ShadowDepth="0" Opacity="1"/>
  127. </Border.Effect>
  128. <!--下拉幕布边界背景设置 MaxHeight="{TemplateBinding MaxDropDownHeight}"-->
  129. <ScrollViewer Margin="0,0,0,0" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" BorderBrush="Gray" BorderThickness="2" >
  130. <!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
  131. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="LightGray" />
  132. </ScrollViewer>
  133. </Border>
  134. </Popup>
  135. </Grid>
  136. </ControlTemplate>
  137. </Setter.Value>
  138. </Setter>
  139. </Style>
  140. </ResourceDictionary>