Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
content pane combobox focus issue
posted

Hello

I am using split pane with content pane, in content pane I having a combobox, if combobox items list is small we dont have any issue, if combobox having big list then only we have issue if we tried to scroll items by clicking on combobox scrollbar buttons its not allowing.

If we make content pane as floatable and then docked back/pinned back to normal position I am able to scroll combobox items using scrollbar buttons.

I tried ContentPane.Activate() method but its not working.

Please suggest me whats going to wrong and thanks in advance.

Thanks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

For combobox i am using below style:

<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="MouseOver">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="MouseOut" x:Name="MouseOut">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="20" />
            </Grid.ColumnDefinitions>
            <Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Fill="{DynamicResource NormalBrush}" Stroke="{DynamicResource NormalBorderBrush}" />
            <Rectangle x:Name="Hover" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Fill="{DynamicResource MouseOverBrush}" Stroke="{DynamicResource NormalBorderBrush}" Opacity="0" Grid.ColumnSpan="2" />
            <Rectangle Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Fill="{DynamicResource LightBrush}" Stroke="{DynamicResource NormalBorderBrush}" />
            <Path Grid.Column="1" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z" />
            <Rectangle d:LayoutOverrides="HorizontalAlignment" Fill="{DynamicResource ShineBrush}" Stroke="{x:Null}" RadiusX="2" RadiusY="2" Margin="0,1.06,0,9.94" VerticalAlignment="Stretch" Height="Auto" Grid.Column="1" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource MouseOver}" />
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard x:Name="MouseOut_BeginStoryboard" Storyboard="{StaticResource MouseOut}" />
                </Trigger.ExitActions>
                <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Rectangle" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Rectangle" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Rectangle" />
                <Setter Property="Stroke" Value="{DynamicResource DisabledBorderBrush}" TargetName="Rectangle" />
                <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
                <Setter Property="Fill" Value="{DynamicResource DisabledForegroundBrush}" TargetName="Arrow" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
        <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />
    </ControlTemplate>
    <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type Control}}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="MinWidth" Value="244" />
        <Setter Property="MaxWidth" Value="244" />
        <Setter Property="Margin" Value="10,5,10,5" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Background" Value="Transparent"/>
        <!--<Setter Property="MaxHeight" Value="95"/>-->
        <Setter Property="MinHeight" Value="20"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Grid>
                        <ToggleButton
                            Grid.Column="2"
                            Template="{DynamicResource ComboBoxToggleButton}"
                            x:Name="ToggleButton" Focusable="True"                            
                            IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                            ClickMode="Release"   />
                        <ContentPresenter
                            x:Name="ContentSite"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Margin="3,3,23,3" 
                            Content="{TemplateBinding SelectionBoxItem}"
                            ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                            ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                            IsHitTestVisible="False" />
                        <TextBox
                            Visibility="Hidden"
                            Template="{DynamicResource ComboBoxTextBox}"
                            HorizontalAlignment="Left" Margin="3,3,23,3"
                            x:Name="PART_EditableTextBox" Style="{x:Null}"
                            VerticalAlignment="Center"
                            Focusable="True"
                            Background="Transparent"
                            IsReadOnly="{TemplateBinding IsReadOnly}" />
                        <Popup
                            IsOpen="{TemplateBinding IsDropDownOpen}"
                            Placement="Bottom" x:Name="Popup"
                            Focusable="True"
                            AllowsTransparency="True"
                            PopupAnimation="Slide">
                            <Grid
                                MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                MinWidth="{TemplateBinding ActualWidth}"
                                x:Name="DropDown"
                                SnapsToDevicePixels="True">
                                <Border x:Name="DropDownBorder"
                                        Background="{DynamicResource LightBrush}"
                                        BorderBrush="{DynamicResource SolidBorderBrush}"
                                        BorderThickness="1" />
                                <ScrollViewer Margin="4,6,4,6"
                                              Style="{DynamicResource NuclearScrollViewer}"  Focusable="True"
                                              SnapsToDevicePixels="True"
                                              HorizontalScrollBarVisibility="Auto"
                                              VerticalScrollBarVisibility="Auto"
                                              CanContentScroll="True">
                                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="false">
                            <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </Trigger>
                        <Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
                            <Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder" />
                            <Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder" />
                        </Trigger>
                        <Trigger Property="IsEditable" Value="true">
                            <Setter Property="IsTabStop" Value="false" />
                            <Setter Property="Visibility" Value="Visible" TargetName="PART_EditableTextBox" />
                            <Setter Property="Visibility" Value="Hidden" TargetName="ContentSite" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style d:IsControlPart="True" TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type Control}}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="MouseOver">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="MouseOut" x:Name="MouseOut">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid SnapsToDevicePixels="true">
                        <Border x:Name="Border" CornerRadius="2,2,2,2" Opacity="0" Background="{DynamicResource SelectedBackgroundBrush}" BorderBrush="{DynamicResource NormalBorderBrush}" BorderThickness="1,1,1,1" />
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,0,0,0" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource MouseOver}" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="MouseOut_BeginStoryboard" Storyboard="{StaticResource MouseOut}" />
                            </Trigger.ExitActions>
                            <Setter Property="Background" Value="{DynamicResource SelectedBackgroundBrush}" TargetName="Border" />
                            <Setter Property="Opacity" TargetName="Border" Value="1" />
                            <Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource NormalBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Parents
No Data
Reply
  • 54937
    Offline posted

    Can you attach a sample that demonstrates the problem? You can attach a sample using the Options tab. Note you could also try setting AllowsTransparency to false in the Popup of your combobox as I know there are issues with WPF (or maybe it's the OS) relating to alpha blended windows.

Children
No Data