123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition Width="30"/>
- </Grid.ColumnDefinitions>
- <Border x:Name="Border"
- Grid.ColumnSpan="2"
- CornerRadius="5"
- BorderBrush="#59A862"
- BorderThickness="1"
- SnapsToDevicePixels="true">
- </Border>
- <Border Grid.Column="1"
- BorderBrush="#444" Name="ButtonBorder"
- CornerRadius="0" BorderThickness="0"
- Background="Transparent" />
- <Border Grid.Column="1">
- <Path x:Name="Arrow"
- Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
- Fill="#59A862"
- Stretch="Fill"
- Height="7"
- Width="10"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"/>
- </Border>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="UIElement.IsMouseOver" Value="True">
- <Setter Property="Panel.Background" TargetName="ButtonBorder" Value="Transparent"/>
- </Trigger>
- <Trigger Property="ToggleButton.IsChecked" Value="True">
- <Setter Property="Panel.Background" TargetName="ButtonBorder" Value="Transparent"/>
- <Setter Property="Shape.Fill" TargetName="Arrow" Value="#498C51"/>
- </Trigger>
- <Trigger Property="UIElement.IsEnabled" Value="False">
- <Setter Property="Panel.Background" TargetName="Border" Value="#498C51"/>
- <Setter Property="Panel.Background" TargetName="ButtonBorder" Value="#498C51"/>
- <Setter Property="Border.BorderBrush" TargetName="ButtonBorder" Value="#498C51"/>
- <Setter Property="TextElement.Foreground" Value="#498C51"/>
- <Setter Property="Shape.Fill" TargetName="Arrow" Value="#498C51"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
- <Border x:Name="PART_ContentHost"
- Focusable="True"
- Background="{TemplateBinding Background}"/>
- </ControlTemplate>
- <Style TargetType="ComboBox">
- <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
- <Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True"/>
- <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
- <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
- <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
- <Setter Property="FrameworkElement.FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="Height" Value="40"/>
- <Setter Property="Width" Value="250"/>
- <Setter Property="FontSize" Value="14"/>
- <Setter Property="Foreground" Value="#59A862"/>
- <Setter Property="HorizontalAlignment" Value="Center"/>
- <Setter Property="Margin" Value="0 10 0 0"/>
- <Setter Property="Cursor" Value="Hand"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ComboBox">
- <Grid>
- <ToggleButton x:Name="ToggleButton"
- Grid.Column="2"
- ClickMode="Press" Focusable="False"
- IsChecked="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
- Template="{StaticResource ComboBoxToggleButton}"/>
- <ContentPresenter Name="ContentSite"
- Margin="5 0"
- IsHitTestVisible="False"
- HorizontalAlignment="Left" VerticalAlignment="Center"
- Content="{TemplateBinding ComboBox.SelectionBoxItem}"
- ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}"
- ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
- <TextBox Name="PART_EditableTextBox" Margin="3 10"
- IsReadOnly="{TemplateBinding IsReadOnly}"
- Visibility="Hidden" Background="Transparent"
- HorizontalAlignment="Left" VerticalAlignment="Center"
- Focusable="True">
- <TextBox.Template>
- <ControlTemplate TargetType="TextBox" >
- <Border Name="PART_ContentHost" Focusable="False" VerticalAlignment="Center"/>
- </ControlTemplate>
- </TextBox.Template>
- </TextBox>
- <Popup Name="Popup" Placement="Bottom"
- Focusable="False" AllowsTransparency="True"
- IsOpen="{TemplateBinding ComboBox.IsDropDownOpen}"
- PopupAnimation="Slide">
- <Grid Name="DropDown" SnapsToDevicePixels="True"
- MinWidth="{TemplateBinding FrameworkElement.ActualWidth}"
- MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
- <Border Name="DropDownBorder"
- Background="White" Margin="1"
- CornerRadius="0" BorderThickness="0"
- BorderBrush="#498C51"/>
- <ScrollViewer Margin="4" SnapsToDevicePixels="True">
- <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
- </ScrollViewer>
- </Grid>
- </Popup>
- <Label x:Name="Watermark"
- VerticalAlignment="Center"
- HorizontalAlignment="Left"
- Foreground="#59A862"
- Visibility="Collapsed"
- Padding="10 0 0 0"
- Content="{TemplateBinding Tag}"
- FontSize="15"/>
- </Grid>
- <ControlTemplate.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="Text" Value=""/>
- </MultiTrigger.Conditions>
- <Setter Property="Visibility" Value="Visible" TargetName="Watermark"/>
- </MultiTrigger>
- <Trigger Property="ItemsControl.HasItems" Value="False">
- <Setter Property="FrameworkElement.MinHeight" TargetName="DropDownBorder" Value="95"/>
- </Trigger>
- <Trigger Property="UIElement.IsEnabled" Value="False">
- <Setter Property="TextElement.Foreground" Value="#498C51"/>
- </Trigger>
- <Trigger Property="ItemsControl.IsGrouping" Value="True">
- <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
- </Trigger>
- <Trigger Property="ComboBox.IsEditable" Value="True">
- <Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
- <Setter Property="UIElement.Visibility" TargetName="PART_EditableTextBox" Value="Visible"/>
- <Setter Property="UIElement.Visibility" TargetName="ContentSite" Value="Hidden"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </ResourceDictionary>
|