Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Custom Combo Box ScrollViewer Issue

$
0
0

HI,

I am creating a Custom control derived from combo box. I need to add few controls above the normal combo items list in the Popup.

I have done it. But whenever I focus on the combo box items using mouseHover, then clicking on the controls(label in the sample) above and move with Mouse left button still pressed, scrolling is happening in the below combo box items list.

Below is the template of the comboBox. For sample, I have added a Label above the ItemsPresenter. this will reproduce the issue. 

<Style x:Key="ComboBoxStyle" TargetType="{x:Type wpfApplication1:CustomComboBox }"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ComboBox}"><Grid Opacity="{TemplateBinding Opacity}"><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="32" /></Grid.ColumnDefinitions><TextBox x:Name="PART_EditableTextBox" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" IsTabStop="True" Margin="0" Padding="{TemplateBinding Padding}" /><ToggleButton x:Name="DropDownToggle" Background="{TemplateBinding Background}" Grid.Column="1" IsChecked="{Binding ElementName=Popup, Path=IsOpen, Mode=TwoWay}"  Focusable="False"></ToggleButton><Popup x:Name="Popup" AllowsTransparency="False" IsOpen="{TemplateBinding IsDropDownOpen}" MaxHeight="{TemplateBinding MaxDropDownHeight}"><Grid Opacity="{TemplateBinding Opacity}"><Border x:Name="PopupBorder" BorderThickness="0" HorizontalAlignment="Stretch"><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0" HorizontalAlignment="Stretch" Opacity="1.0" Padding="0"><Grid><Grid.RowDefinitions><RowDefinition Height="Auto"></RowDefinition><RowDefinition Height="*"></RowDefinition></Grid.RowDefinitions><StackPanel Grid.Row="0" Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" ><Label Foreground="#ff999999" Content="Lable above the ComboBox items" Focusable="False"></Label><!-- Some Other Controls --><Separator HorizontalAlignment="Stretch" IsEnabled="False" /></StackPanel><ScrollViewer x:Name="ScrollViewer" Grid.Row="1" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"><ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle"/></ScrollViewer></Grid></Border></Border></Grid></Popup></Grid></ControlTemplate></Setter.Value></Setter></Style>


<wpfApplication1:CustomComboBox Width="200" Height="30" Style="{StaticResource ComboBoxStyle}" ItemsSource="{Binding ItemsList}" IsDropDownOpen="True" MaxDropDownHeight="150"></wpfApplication1:CustomComboBox>

Kindly let me know how to stop this scrolling whenever I Mouse move in pressed state in the items above the comboBoxItems list.

Below is the screen shot of the combo box.



Viewing all articles
Browse latest Browse all 18858


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>