ComboBox stays open after focus lost and parent no longer visible

3 posts, 0 answers
  1. Kevin Finke
    Kevin Finke avatar
    7 posts
    Member since:
    Jan 2006

    Posted 16 Apr 2012 Link to this post

    We have RadComboBoxes used throughout our application.  I cannot say for certain whether this is a new bug with 2012 Q1, but now if I click to expand the drop down, and then without selecting an item, but actually navigating away from the "page" (view, tab, etc) that contains the drop down, the drop down area remains visible.  It appears to be doing it for all instances, so I doubt that it's a problem with the way that it's declared.
    Is this a known issue?
  2. Georgi
    Admin
    Georgi avatar
    349 posts

    Posted 19 Apr 2012 Link to this post

    Hello Kevin,

    Can you confirm that you are clicking on a browsers menu (view tab) or do you mean something else? If so clicking somewhere out of the Silverlight plugin should not close the ComboBox. Usually the DropDown button of the ComboBox should be closed on mouse events (MouseLeftButtonDown) or when the focus is lost.  If you are clicking somewhere in the Silverlight plugin, can you please specify where you are clicking (video or simple project would be great)?


    Regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. David
    David avatar
    5 posts
    Member since:
    Sep 2008

    Posted 22 Apr 2012 Link to this post

    Hi Guys
    I've seen this (or similar) behaviour in one of my applications too. The workaround I found, is to set the background of the control that you click that doesn't close the RadComboBox. For example, if the RadCombo is hosted in a RadWindow. Set the background of the RadWindow to transparent, or a colour. Leaving it 'null' will mean that clicking on it doesn't close the dropdown.

    See the code for a sample project that shows the behaviour. I'm using version 2012.1.215.1050 of the Telerik Silverlight controls.

    I couldn't upload a zip file of the project, unfortunately.

    I hope this helps!

    Dave

    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
     
    namespace RadComboTestApp
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this.LayoutRoot.Background = null;
            }
     
            private void Button_Click1(object sender, RoutedEventArgs e)
            {
                this.LayoutRoot.Background = new SolidColorBrush(Colors.Transparent);
            }
     
            private void Button_Click2(object sender, RoutedEventArgs e)
            {
                this.LayoutRoot.Background = new SolidColorBrush(Colors.LightGray);
            }
        }
    }

    <UserControl
        x:Class="RadComboTestApp.MainPage"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
        Width="600">
     
        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="180"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
     
            <StackPanel Orientation="Vertical" Grid.ColumnSpan="3" >
                <TextBlock Text="Open the RadCombo, click the background of the window below the second ComboBox, and the dropdown stays there. Do the same with the standard ComboBox and it closes. Now, open the RadComboBox, and click a label or this text, and it closes." TextWrapping="Wrap" Margin="8" />
                <TextBlock Text="The workaround is to set the background of 'LayoutRoot' to something." TextWrapping="Wrap" Margin="8" />
                <TextBlock Text="Set the background to Grey, open the RadComboBox and click in the white area to the right. Again, the RadCombo doesn't close." TextWrapping="Wrap" Margin="8" />
                <StackPanel Orientation="Horizontal">
                    <Button Content="Set Background to Null" Click="Button_Click" Width="180" Margin="8"/>
                    <Button Content="Set Background to Transparent" Click="Button_Click1" Width="190" Margin="8"/>
                    <Button Content="Set Background to Grey" Click="Button_Click2" Width="160" Margin="8"/>
                </StackPanel>
                <Grid Height="20"/>
            </StackPanel>
     
            <TextBlock Text="Select a RADCOMBO Option:" Margin="4" Grid.Row="1" VerticalAlignment="Center"/>
            <telerik:RadComboBox Grid.Row="1" Grid.Column="1" Width="180" Margin="4" HorizontalAlignment="Left">
                <telerik:RadComboBoxItem Content="Item One" />
                <telerik:RadComboBoxItem Content="Item Two" />
                <telerik:RadComboBoxItem Content="Item Three" />
                <telerik:RadComboBoxItem Content="Item Four" />
                <telerik:RadComboBoxItem Content="Item Five" />
            </telerik:RadComboBox>
     
            <TextBlock Text="Select a COMBO Option:" Margin="4" Grid.Row="3" VerticalAlignment="Center"/>
            <ComboBox Grid.Row="3" Grid.Column="1" Width="250" Margin="4" HorizontalAlignment="Left">
                <ComboBoxItem Content="Item One"/>
                <ComboBoxItem Content="Item Two"/>
                <ComboBoxItem Content="Item Three"/>
                <ComboBoxItem Content="Item Four"/>
                <ComboBoxItem Content="Item Five"/>
            </ComboBox>
        </Grid>
    </UserControl>
Back to Top