Files
BeWoPlaner/BeWo.Styles/ControlStyles/NullItemComboBoxStyles.xaml

148 lines
9.0 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls">
<!-- NullItemComboBox -->
<Style x:Key="PrimaryNullItemComboBox" TargetType="uc:NullItemComboBox">
<Setter Property="Margin" Value="3" />
<Setter Property="Height" Value="23" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource ComboBoxFocusVisual}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="1" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Path=.}" TextWrapping="NoWrap" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type uc:NullItemComboBox}">
<Grid SnapsToDevicePixels="true">
<Border
x:Name="Bd"
Padding="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid Grid.IsSharedSizeScope="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="ComboBoxButton" />
</Grid.ColumnDefinitions>
<Border
x:Name="SelectedItemBorder"
Grid.ColumnSpan="2"
Margin="2,1,20,1">
<ContentPresenter
Margin="3,0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ToggleButton
Grid.Column="0"
Grid.ColumnSpan="3"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{DynamicResource ComboBoxTransparentButtonStyle}" />
<Label
x:Name="label_nullText"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="5,3,20,3"
Padding="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{TemplateBinding NullText}"
IsHitTestVisible="False"
Visibility="Hidden" />
</Grid>
</Border>
<Popup
x:Name="PART_Popup"
AllowsTransparency="true"
Focusable="false"
IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
<Microsoft_Windows_Themes:SystemDropShadowChrome
x:Name="Shdw"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Color="Transparent">
<Border
x:Name="DropDownBorder"
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"
BorderThickness="1">
<ScrollViewer>
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</Microsoft_Windows_Themes:SystemDropShadowChrome>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelectionBoxHighlighted" Value="true" />
<Condition Property="IsDropDownOpen" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="#FF000000" />
</MultiTrigger>
<Trigger Property="IsSelectionBoxHighlighted" Value="true">
<Setter TargetName="SelectedItemBorder" Property="Background" Value="{DynamicResource ControlSelectedBackgroundBrush}" />
</Trigger>
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true">
<Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />
<Setter TargetName="Shdw" Property="Color" Value="#71000000" />
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
<Trigger Property="SelectedItem" Value="{x:Null}">
<Setter TargetName="label_nullText" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEditable" Value="true">
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Padding" Value="0,1" />
<Setter Property="Template" Value="{DynamicResource ComboBoxEditableTemplate}" />
</Trigger>
</Style.Triggers>
</Style>
<Style
x:Key="EnumTranslationNullItemComboBox"
BasedOn="{StaticResource PrimaryNullItemComboBox}"
TargetType="{x:Type uc:NullItemComboBox}">
<Setter Property="ItemTemplate" Value="{DynamicResource ListItemView}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="MaxWidth" Value="400" />
</Style>
</ResourceDictionary>