Sic01/FrameworkLocal/UICore/Style/DeepBlue/ComboBoxStyle.xaml

233 lines
12 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="ComboBox">
<Setter Property="FontFamily" Value="Arial,SimSun" />
<Setter Property="Background" Value="#FFDCF7F6" />
</Style>
<Style
x:Key="EventComboBox"
BasedOn="{StaticResource {x:Type ComboBox}}"
TargetType="ComboBox">
<Setter Property="Height" Value="28" />
<Setter Property="FontSize" Value="14" />
</Style>
<Style x:Key="ComboxStyleBtn" TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<!-- 下拉按钮内部背景色 -->
<Border
x:Name="Back"
Background="#56b6e6"
BorderBrush="Transparent"
BorderThickness="1">
<!-- 下拉按钮内边框 -->
<Path
Name="PathFill"
Width="10"
Height="6"
Data="M5,0 L10,10 L0,10 z"
Fill="#03ffea"
RenderTransformOrigin="0.5,0.5"
Stretch="Fill"
StrokeThickness="0">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="180" />
<TranslateTransform />
</TransformGroup>
</Path.RenderTransform>
</Path>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="PathFill" Property="Fill" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ComboxStyleBtnLabel" TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Label
Grid.Column="0"
Margin="0"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
Background="{TemplateBinding Background}"
BorderThickness="0"
Foreground="{TemplateBinding Foreground}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TopFrameComboBoxStyle" TargetType="ComboBox">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Background" Value="{StaticResource MessagesInformationBackgroundBrush}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Category}" Value="Error">
<Setter Property="Foreground" Value="{StaticResource MessagesErrorForegroundBrush}" />
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Warning">
<Setter Property="Foreground" Value="{StaticResource MessagesWarningForegroundBrush}" />
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Information">
<Setter Property="Foreground" Value="{StaticResource MessagesInformationForegroundBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding UtcTimestamp, Converter={StaticResource UtcTimeToTextConverter}, ConverterParameter=HH:mm:ss.fff}" />
<TextBlock
Grid.Column="1"
Margin="8,0,0,0"
Text="{Binding Source}" />
<TextBlock
Grid.Column="2"
Margin="8,0,0,0"
Text="{Binding Type}" />
<TextBlock
Grid.Column="3"
Margin="8,0,0,0"
Text="{Binding Message}" />
</Grid>
</ContentControl>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TopPanelComboBoxStyle" TargetType="ComboBox">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<!-- ComBoxItem -->
<Style TargetType="ComboBoxItem">
<Setter Property="MinHeight" Value="22" />
<Setter Property="MinWidth" Value="60" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border Name="Back" Background="{TemplateBinding Background}">
<ContentPresenter
Margin="10,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ContentSource="{Binding Source}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.3*" MaxWidth="30" />
</Grid.ColumnDefinitions>
<!-- 文字区域背景和边线样式 -->
<Border
Grid.Column="0"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="1,0,0,1">
<Label
Grid.Column="0"
Margin="0"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
Background="{TemplateBinding Background}"
BorderThickness="0"
Content="{TemplateBinding Text}"
Foreground="{TemplateBinding Foreground}" />
<!--<ToggleButton BorderThickness="0" BorderBrush="Gray" Style="{StaticResource ComboxStyleBtnLabel}" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"></ToggleButton>-->
</Border>
<!-- 右侧下拉button设置 -->
<Border
Grid.Column="1"
BorderBrush="Gray"
BorderThickness="0,1,1,1"
CornerRadius="0,1,1,0">
<ToggleButton
BorderBrush="Gray"
BorderThickness="3"
ClickMode="Press"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ComboxStyleBtn}" />
</Border>
<!-- 弹出popup整体设置 -->
<Popup
x:Name="Popup"
AllowsTransparency="True"
Focusable="False"
IsOpen="{TemplateBinding IsDropDownOpen}"
Placement="Bottom"
PopupAnimation="Slide">
<!-- 弹出popup边框 -->
<Border
x:Name="DropDown"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
BorderBrush="Gray"
BorderThickness="1,0,1,1"
CornerRadius="1"
SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect
BlurRadius="2"
Opacity="1"
ShadowDepth="0"
Color="LightGray" />
</Border.Effect>
<!-- 下拉幕布边界背景设置 MaxHeight="{TemplateBinding MaxDropDownHeight}" -->
<ScrollViewer
Margin="0,0,0,0"
BorderBrush="Gray"
BorderThickness="2"
HorizontalScrollBarVisibility="Auto"
SnapsToDevicePixels="True"
VerticalScrollBarVisibility="Auto">
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
<StackPanel
Background="LightGray"
IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>