wpf - combobox style css
Personalizar el ScrollViewer en WPF (0)
Estoy desarrollando una aplicación que tiene el ComboBox personalizado.
La apariencia de ComboBox debería gustarle.
He modificado el ControlTemplate de ComboBox para que se vea como el anterior.
El problema es: cuando Up RepeatButton está desactivado también (programáticamente estoy desactivando eso) los elementos se seleccionan cuando sigo presionando el botón Repeat desactivado.
La plantilla de control que estoy usando es:
<Setter
Property ="SnapsToDevicePixels"
Value ="True"
/>
<Setter
Property ="FocusVisualStyle"
Value ="{DynamicResource ComboFocusVisualStyle}"
/>
<Setter
Property ="Foreground"
Value ="Black"
/>
<Setter
Property ="Template"
>
<Setter.Value>
<ControlTemplate
TargetType ="{x:Type ComboBox}"
>
<Grid>
<Border
CornerRadius ="3"
BorderThickness ="0,0,0,.7"
BorderBrush ="WhiteSmoke"
>
<Border
Name ="brd1"
CornerRadius ="3"
BorderBrush ="{StaticResource ComboBorderBrush}"
BorderThickness ="1,1,1,1"
Background ="{TemplateBinding Background}"
ToolTip ="{TemplateBinding SelectionBoxItem, Converter={StaticResource ToolTipConverter}, ConverterParameter=PrinterInfoCol}"
>
<Grid>
<ContentPresenter
x:Name ="ContentSite"
HorizontalAlignment ="Left"
VerticalAlignment ="Center"
IsHitTestVisible ="False"
>
<ContentPresenter.Content>
<Grid
Width ="180"
>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width ="180"
/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column ="0"
Margin ="10,0,0,0"
Text ="{TemplateBinding SelectionBoxItem, Converter={StaticResource TextConverter}}"
TextTrimming ="CharacterEllipsis"
VerticalAlignment ="Center"
Foreground ="Black"
/>
</Grid>
</ContentPresenter.Content>
</ContentPresenter>
<!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
<ToggleButton
x:Name ="ToggleButton"
Template ="{DynamicResource ComboBoxToggleButton}"
Focusable ="false"
IsChecked ="{Binding Path=IsDropDownOpen,
Mode =TwoWay,
RelativeSource ={RelativeSource TemplatedParent}}"
ClickMode ="Press"
Margin ="16,5,2,2"
/>
</Grid>
</Border>
</Border>
<!-- The Popup shows the list of items in the
ComboBox. IsOpen is databound to IsDropDownOpen
which is toggled via the ComboBoxToggleButton -->
<Popup
x:Name ="PART_popup"
IsOpen ="{TemplateBinding IsDropDownOpen}"
ScrollViewer.VerticalScrollBarVisibility ="Auto"
Placement ="Bottom"
Focusable ="False"
MinWidth ="{Binding ElementName=brd1, Path=ActualWidth}"
AllowsTransparency ="True"
PopupAnimation ="None"
MaxWidth ="325"
>
<dropShadow:SystemDropShadowChrome
Visibility ="Visible"
Margin ="3"
>
<Grid
x:Name ="DropDown"
SnapsToDevicePixels ="True"
Margin ="0,-1,0,0"
>
<Grid.RowDefinitions>
<RowDefinition
Height="18"
/>
<RowDefinition
Height="*"
/>
<RowDefinition
Height="18"
/>
</Grid.RowDefinitions>
<Border
x:Name ="DropDownBorder"
Grid.Row="0"
Grid.RowSpan="3"
Background ="{StaticResource dropDownBackground}"
BorderBrush ="{DynamicResource SolidBorderBrush}"
BorderThickness ="1"
/>
<RepeatButton
x:Name ="upRepeatButton"
Grid.Row ="0"
Margin ="1,0"
ClickMode ="Press"
Style ="{DynamicResource ScrollBarLineButton}"
Height ="18"
Content ="M 0 4 L 8 4 L 4 0 Z"
/>
<ScrollViewer
Name ="scrollCombo"
Margin ="1,0,1,0"
Style ="{DynamicResource ComboBoxScrollViewerStyle}"
Grid.Row ="1"
SnapsToDevicePixels ="True"
HorizontalScrollBarVisibility ="Hidden"
VerticalScrollBarVisibility ="Hidden"
CanContentScroll ="False"
HorizontalAlignment ="Stretch"
Focusable ="False"
>
<ItemsPresenter
Margin="0,18"
/>
</ScrollViewer>
<RepeatButton
x:Name ="downRepeatButton"
Grid.Row ="2"
Margin ="1,0"
ClickMode ="Press"
Style ="{StaticResource ScrollBarLineButton}"
Height ="18"
Content ="M 0 0 L 4 4 L 8 0 Z"
/>
</Grid>
</dropShadow:SystemDropShadowChrome>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<!-- This forces the DropDown to have a minimum
size if it is empty -->
<Trigger
Property ="HasItems"
Value ="false"
>
<Setter
Property ="MinHeight"
Value ="95"
TargetName ="DropDownBorder"
/>
</Trigger>
<Trigger
Property ="IsGrouping"
Value ="True"
>
<Setter
Property ="ScrollViewer.CanContentScroll"
Value ="false"
/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Alguna idea sobre esto?