Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAML ReadOnly ComboBox

To set up a ReadOnly ComboBox in XAML (WPF), you have to set up a ComboBox and a TextBox showing only one of them according to a pair of properties IsReadOnly/IsEditable that must exist on your ViewModel. Note that on this sample "UserNVL" must exist in the resources and it should be a NameValueList collection that allows us to convert ID to names. In this case the RecipientID is the key for a user name. Note also the VisibilityConverter must also exist in the resources and it's a standard BooleanToVisibilityConverter.

Gosh! This was so hard to find I had to made it myself. This allows the user the select the content of the text box. No way a disabled ComboBox would ever allow you to do it.

like image 336
Tiago Freitas Leal Avatar asked Feb 02 '23 22:02

Tiago Freitas Leal


2 Answers

There are two properties named IsHitTestVisible & IsTabVisible. the former makes the control deaf to mouse events and the latter to keyboard events. This could help you as it would not give the disabled look to your combo box but you will succeed in making a read only combo box.. Source :- http://www.telerik.com/community/forums/wpf/combobox/isreadonly-does-seem-to-work.aspx

like image 106
user1744082 Avatar answered Feb 06 '23 10:02

user1744082


Why not just set IsEnabled=false?

like image 45
Robert Levy Avatar answered Feb 06 '23 10:02

Robert Levy