Derived ComboBox - strange behavior with OnClick event

Editors for WPF Forum

Posted 14 years ago by Kevin Drapel
Version: 11.1.0542
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar
Hi,

I encountered a strange behavior in our application with the ComboBox control. Basically, we are using a class that inherits from Ribbon.Controls.ComboBox with some additional code. This new control is firing unexpected OnClick events even if the mouse was not directly involved in the operations. For example, first clicking on the combobox to open the dropdown (mouse is never used afterwards), then moving in the dropdown list with the keyboard , then pressing ESC key and pressing the right or left arrow key would launch the event. Normally, I was expected the ESC key to close the dropdown without a click event being fired at the end.

I could reproduce it with the bare minimum and will send you a full project that exactly shows this behavior.

The main reproduction code looks like this:


    public class MyComboBox : ActiproSoftware.Windows.Controls.Ribbon.Controls.ComboBox {
    }
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            List<string> s = new List<string>() { "a", "b", "c" };
            comboBox1.ItemsSource = s;
        }

        private void comboBox1_Click(object sender, ActiproSoftware.Windows.Controls.Ribbon.Controls.ExecuteRoutedEventArgs e) {
            MessageBox.Show("CLICK ??");
        }
    } 


<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon" xmlns:WpfApplication2="clr-namespace:WpfApplication2">
    <Grid>
        <WpfApplication2:MyComboBox Height="23" HorizontalAlignment="Left" Margin="82,97,0,0" x:Name="comboBox1" VerticalAlignment="Top" Width="252" Click="comboBox1_Click" />
    </Grid>
</Window>

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kevin,

Thanks for the sample. We are raising our Click event as well as executing the command whenever the selection is changed. In your scenario, pressing the right arrow is changing the selection from nothing to 'a' (from base ComboBox code), and thus triggers all that logic.


Actipro Software Support

The latest build of this product (v24.1.3) was released 28 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.