Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--COMBOBOX-->
- <Style x:Key="{x:Type ComboBox}" TargetType="ComboBox">
- <Setter Property="SnapsToDevicePixels" Value="true"/>
- <Setter Property="OverridesDefaultStyle" Value="true"/>
- <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
- <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
- <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
- <Setter Property="MinWidth" Value="120"/>
- <Setter Property="Height" Value="25"/>
- <Setter Property="FontFamily" Value="Verdana" />
- <Setter Property="FontSize" Value="12" />
- <Setter Property="Validation.ErrorTemplate">
- <Setter.Value>
- <ControlTemplate>
- <DockPanel LastChildFill="true">
- <Border x:Name="errorBorder" Background="Red" DockPanel.Dock="right" Margin="5,0,0,0" Width="10" Height="10" CornerRadius="10"
- ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
- <TextBlock Text="!" VerticalAlignment="center" HorizontalAlignment="center" FontWeight="Bold" FontSize="8" Foreground="white" />
- </Border>
- <AdornedElementPlaceholder Name="customAdorner" VerticalAlignment="Center" >
- <Border BorderBrush="red" BorderThickness="1" />
- </AdornedElementPlaceholder>
- </DockPanel>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ComboBox">
- <Grid>
- <ToggleButton
- Name="ToggleButton"
- Template="{StaticResource ComboBoxToggleButton}"
- Grid.Column="2"
- Focusable="false"
- IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
- ClickMode="Press">
- </ToggleButton>
- <ContentPresenter
- Name="ContentSite"
- IsHitTestVisible="False"
- Content="{TemplateBinding SelectionBoxItem}"
- ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
- ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
- Margin="3,3,23,3"
- VerticalAlignment="Center"
- HorizontalAlignment="Left" />
- <TextBox x:Name="PART_EditableTextBox"
- Style="{x:Null}"
- Template="{StaticResource ComboBoxTextBox}"
- HorizontalAlignment="Left"
- VerticalAlignment="Center"
- Margin="3,3,23,3"
- Focusable="True"
- Background="Transparent"
- Visibility="Hidden"
- IsReadOnly="{TemplateBinding IsReadOnly}"/>
- <Popup
- Name="Popup"
- Placement="Bottom"
- IsOpen="{TemplateBinding IsDropDownOpen}"
- AllowsTransparency="True"
- Focusable="False"
- PopupAnimation="Slide">
- <Grid
- Name="DropDown"
- SnapsToDevicePixels="True"
- MinWidth="{TemplateBinding ActualWidth}"
- MaxHeight="{TemplateBinding MaxDropDownHeight}">
- <Border
- x:Name="DropDownBorder"
- Background="{StaticResource NormalBrush}"
- BorderThickness="1"
- BorderBrush="{StaticResource SolidBorderBrush}"/>
- <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
- <ScrollViewer.Background>
- <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
- <GradientStop Offset="0" Color="#DCDCD8"/>
- <GradientStop Offset=".91" Color="White"/>
- </LinearGradientBrush>
- </ScrollViewer.Background>
- <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
- </ScrollViewer>
- </Grid>
- </Popup>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="HasItems" Value="false">
- <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
- </Trigger>
- <Trigger Property="IsEnabled" Value="false">
- <Setter TargetName="DropDownBorder" Property="BorderBrush" Value="#EEEEEE"/>
- <Setter Property="Foreground" Value="#888888"/>
- </Trigger>
- <Trigger Property="IsGrouping" Value="true">
- <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
- </Trigger>
- <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
- <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4"/>
- <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/>
- </Trigger>
- <Trigger Property="IsEditable" Value="true">
- <Setter Property="IsTabStop" Value="false"/>
- <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/>
- <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
- </Trigger>
- <Trigger Property="Validation.HasError" Value="true">
- <Setter Property="Margin" Value="0 0 15 0" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement