This is a migrated thread and some comments may be shown as answers.

RadDropDownButton loses Enter/Space behavior after multiple clicks

1 Answer 103 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 06 Mar 2013, 10:39 PM
Hello,
I'm seeing an issue with the RadDropDownButton and am wondering curious if there is a work around for my scenario. When focus is on a RadDropDownButton pressing 'Enter' or 'Space' normally causes the button to display the DropDownContent; what I'm seeing is this keyboard functionality stops working after the following steps.

1. User clicks the RadDropDownButton. This causes the DropDownContent to display as expected.
2. User clicks the RadDropDownButton again. This closes the DropDownContent to hide as expected and focus is once again on the button itself.

Unfortunately it is at this point that 'Enter' and 'Space' seem to no longer work. Even after tabbing off of the control and returning the keyboard functions do not work. Interestingly pressing 'Space' actually changes the button visual to the 'Pressed' state but the DropDownContent is not displayed. Any ideas to get the keyboard functionality work would be greatly appreciated. We are currently using assemblies version 2012.2.912.40. Thanks much for any feedback!

Below is the code for a small test app that exhibits the behavior outlined above.

MainWindow.xaml.cs

using System.Windows;
 
namespace DropDownButtonKeyBehavior
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
 
            DataContext = new ViewModel();
        }
    }
}


MainWindow.xaml


<Window x:Class="DropDownButtonKeyBehavior.MainWindow"
        xmlns:commands="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism"
        Title="MainWindow" Height="400" Width="200">
     
    <Window.Resources>
        <DataTemplate x:Key="DropDownContent">
            <Grid Background="Orange" Height="300" Width="300">
                <Grid Margin="5">
                     
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>         
                         
                     <telerik:RadDatePicker />
                      
                    <Button Name="Save" Grid.Row="1" Content="OK" HorizontalAlignment="Right" Width="105" />
                     
                </Grid>        
            </Grid>
        </DataTemplate>
    </Window.Resources>
     
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition/>     
            <RowDefinition/>     
        </Grid.RowDefinitions>
 
        <telerik:RadDropDownButton Content="Click Me For Popup" IsOpen="{Binding IsExpanded}" Background="Gray" HorizontalAlignment="Center" VerticalAlignment="Center"  Height="90" Width="90" commands:Click.Command="{Binding ExpandCommand}" commands:Click.CommandParameter="{Binding}">
            <telerik:RadDropDownButton.DropDownContent>
                <ContentControl ContentTemplate="{StaticResource DropDownContent}" DataContext="{Binding}" Content="{Binding}" />
            </telerik:RadDropDownButton.DropDownContent>
        </telerik:RadDropDownButton>
         
        <TextBox x:Name="FocusHolder" Grid.Row="1"/>
     
    </Grid>
</Window>



ViewModel.cs


using System;
using System.ComponentModel;
 
using Microsoft.Practices.Prism.Commands;
 
namespace DropDownButtonKeyBehavior
{
    public class ViewModel : INotifyPropertyChanged
    {
        #region ViewModel Members
         
        private DelegateCommand<object> mExpandCommand;
        public DelegateCommand<object> ExpandCommand
        {
            get
            {
                return mExpandCommand ?? ( mExpandCommand = new DelegateCommand<object>( _OnExpandCommandExecuted ) );
            }
        }
 
        private bool mIsExpanded;
        public bool IsExpanded
        {
            get
            {
                return mIsExpanded;
            }
            set
            {
                if( mIsExpanded != value )
                {
                    mIsExpanded = value;
                    OnPropertyChanged( "IsExpanded" );
                }
            }
        }
 
        #endregion ViewModel Members
 
        #region Ëvents
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        #endregion Ëvents
 
        #region Private Members
 
        private void _OnExpandCommandExecuted( object obj )
        {
            IsExpanded = true;
        }
 
        #endregion Private Members
 
        #region Protected Members
 
        protected virtual void OnPropertyChanged( string propertyName )
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if( handler != null )
            {
                handler( this, new PropertyChangedEventArgs( propertyName ) );
            }
        }
 
        #endregion Protected Members
 
    }
}

1 Answer, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 08 Mar 2013, 05:20 PM
Hello Jason,
Thank you for the feedback! It seem that this is a bug in our RadDropDownButton and I've logged it in our PITS under the name "DropDownButton doesn't open on Enter if before that you've opened/closed the button with mouse". It'll be ready for tracking and voting tomorrow the latest.
I've attached a project with sample workaround for this issue - I use an attached property to handle the KeyDown event and manually set the IsOpen property of the DropDownButton.
I've updated your telerik account and if you have further questions please feel free to ask.

Kind regards,
Zarko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Buttons
Asked by
Jason
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Share this question
or