Advertisement
rodrigo_cripto

Untitled

Mar 24th, 2015
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 6.40 KB | None | 0 0
  1. <!--COMBOBOX-->
  2. <Style x:Key="{x:Type ComboBox}" TargetType="ComboBox">
  3.     <Setter Property="SnapsToDevicePixels" Value="true"/>
  4.     <Setter Property="OverridesDefaultStyle" Value="true"/>
  5.     <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  6.     <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  7.     <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
  8.     <Setter Property="MinWidth" Value="120"/>
  9.     <Setter Property="Height" Value="25"/>
  10.     <Setter Property="FontFamily" Value="Verdana" />
  11.     <Setter Property="FontSize" Value="12" />
  12.     <Setter Property="Validation.ErrorTemplate">
  13.         <Setter.Value>
  14.             <ControlTemplate>
  15.                 <DockPanel LastChildFill="true">
  16.                     <Border x:Name="errorBorder" Background="Red" DockPanel.Dock="right" Margin="5,0,0,0" Width="10" Height="10" CornerRadius="10"
  17.                            ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
  18.                         <TextBlock Text="!" VerticalAlignment="center" HorizontalAlignment="center" FontWeight="Bold" FontSize="8" Foreground="white" />
  19.                     </Border>
  20.                     <AdornedElementPlaceholder Name="customAdorner" VerticalAlignment="Center" >
  21.                         <Border BorderBrush="red" BorderThickness="1" />
  22.                     </AdornedElementPlaceholder>
  23.                 </DockPanel>
  24.             </ControlTemplate>
  25.         </Setter.Value>
  26.     </Setter>
  27.     <Setter Property="Template">
  28.         <Setter.Value>
  29.             <ControlTemplate TargetType="ComboBox">
  30.                 <Grid>
  31.                     <ToggleButton
  32.                        Name="ToggleButton"
  33.                        Template="{StaticResource ComboBoxToggleButton}"
  34.                        Grid.Column="2"
  35.                        Focusable="false"
  36.                        IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
  37.                        ClickMode="Press">
  38.                     </ToggleButton>
  39.                     <ContentPresenter
  40.                        Name="ContentSite"
  41.                        IsHitTestVisible="False"
  42.                        Content="{TemplateBinding SelectionBoxItem}"
  43.                        ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
  44.                        ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
  45.                        Margin="3,3,23,3"
  46.                        VerticalAlignment="Center"
  47.                        HorizontalAlignment="Left" />
  48.                     <TextBox x:Name="PART_EditableTextBox"
  49.                        Style="{x:Null}"
  50.                        Template="{StaticResource ComboBoxTextBox}"
  51.                        HorizontalAlignment="Left"
  52.                        VerticalAlignment="Center"
  53.                        Margin="3,3,23,3"
  54.                        Focusable="True"
  55.                        Background="Transparent"
  56.                        Visibility="Hidden"
  57.                        IsReadOnly="{TemplateBinding IsReadOnly}"/>
  58.                     <Popup
  59.                        Name="Popup"
  60.                        Placement="Bottom"
  61.                        IsOpen="{TemplateBinding IsDropDownOpen}"
  62.                        AllowsTransparency="True"
  63.                        Focusable="False"
  64.                        PopupAnimation="Slide">
  65.                         <Grid
  66.                        Name="DropDown"
  67.                        SnapsToDevicePixels="True"                
  68.                        MinWidth="{TemplateBinding ActualWidth}"
  69.                        MaxHeight="{TemplateBinding MaxDropDownHeight}">
  70.                             <Border
  71.                        x:Name="DropDownBorder"
  72.                        Background="{StaticResource NormalBrush}"
  73.                        BorderThickness="1"
  74.                        BorderBrush="{StaticResource SolidBorderBrush}"/>
  75.                             <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
  76.                                 <ScrollViewer.Background>
  77.                                     <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
  78.                                         <GradientStop Offset="0" Color="#DCDCD8"/>
  79.                                         <GradientStop Offset=".91" Color="White"/>
  80.                                     </LinearGradientBrush>
  81.                                 </ScrollViewer.Background>
  82.                                 <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
  83.                             </ScrollViewer>
  84.                         </Grid>
  85.                     </Popup>
  86.                 </Grid>
  87.                 <ControlTemplate.Triggers>
  88.                     <Trigger Property="HasItems" Value="false">
  89.                         <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
  90.                     </Trigger>
  91.                     <Trigger Property="IsEnabled" Value="false">
  92.                         <Setter TargetName="DropDownBorder" Property="BorderBrush" Value="#EEEEEE"/>
  93.                         <Setter Property="Foreground" Value="#888888"/>
  94.                     </Trigger>
  95.                     <Trigger Property="IsGrouping" Value="true">
  96.                         <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  97.                     </Trigger>
  98.                     <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
  99.                         <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4"/>
  100.                         <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/>
  101.                     </Trigger>
  102.                     <Trigger Property="IsEditable" Value="true">
  103.                         <Setter Property="IsTabStop" Value="false"/>
  104.                         <Setter TargetName="PART_EditableTextBox" Property="Visibility"    Value="Visible"/>
  105.                         <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
  106.                     </Trigger>
  107.                     <Trigger Property="Validation.HasError" Value="true">
  108.                         <Setter Property="Margin" Value="0 0 15 0" />
  109.                     </Trigger>
  110.                 </ControlTemplate.Triggers>
  111.             </ControlTemplate>
  112.         </Setter.Value>
  113.     </Setter>
  114. </Style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement