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

ComboBox IsReadOnly + MouseEnter and MouseLeave

1 Answer 153 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 2
B asked on 27 May 2015, 06:46 AM

Hi,

 I need a ComboBox where

  1. The user can't select items with the mouse
  2. The user can't select items with the keyboard
  3. The MouseEnter and MouseLeave events still fire

I thought setting IsReadOnly to true would make the control readonly, but that doesnt seem to do anything? 

So far the only thing that gets close is the code below, but that seems to still allow keyboard selection to slip through about 1 in 3 tries despite the flag.

Is there a "real" way to do this? I mean one that is not so hacked and that works all the time?

The way the control looks is not much of an issue (e.g. IsEnabled = false is fine), but I do need the MouseEnter and MouseLeave events and the user should not be able to change the value in any way.

Regards,

Bayram

if (isReadOnly)
{
    c.MainComboBox.MaxDropDownHeight = 0;
    c.MainComboBox.CanKeyboardNavigationSelectItems = false;
}
else
{
    c.MainComboBox.MaxDropDownHeight = 300;
    c.MainComboBox.CanKeyboardNavigationSelectItems = true;
}
c.MainComboBox.IsReadOnly = isReadOnly;

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 29 May 2015, 01:25 PM
Hi Demir,

In order to prevent the user from selection RadComboBoxItems you could disable them. That could easily be achieve using ItemContainerStyle and inside a Setter set the IsEnabled property to "False" - thus the items would be disable and the user won't be able to select it with the mouse or the keyboard. At the same time the MouseLeave and MouseEnter events should fire as expected. Please, check the following article from our help documentation that provides a detailed information how to achieve the described above approach:
http://docs.telerik.com/devtools/wpf/controls/radcombobox/howto/enable-disable-radcombobox-items#enabledisable-items-using-itemcontainerstyle

Hopes this helps.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
B
Top achievements
Rank 2
Answers by
Nasko
Telerik team
Share this question
or