Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In xaml set the combobox property IsEditable="False" and Text="Test input"
Posted
Updated 18-Jul-19 23:01pm
Comments
Kornfeld Eliyahu Peter 3-Jun-15 6:49am    
How do you interpret 'read-only' in the context of 'combo-box'?
CHill60 3-Jun-15 7:02am    
Good point - you can still select the items :)
Kornfeld Eliyahu Peter 3-Jun-15 7:29am    
I think this is pure case of RTFM...
CHill60 3-Jun-15 7:32am    
LOL!

You need to include an item "Test input" and set IsSelected="True" e.g.
XML
<ComboBox IsEditable="False" >
    <ComboBoxItem IsSelected="True">
        Test Input
    </ComboBoxItem>
</ComboBox>


[Edit - further info after OP clarification of requirement]

There are various options, rather than re-inventing the wheel I suggest reading the suggestions on the following links and choose the method that best suits your application
SO Post 1[^]

SO post 2[^]
 
Share this answer
 
v2
Comments
Member 11603144 3-Jun-15 9:12am    
I don't need to include the content into the list item
CHill60 3-Jun-15 10:00am    
Well that is how you display text in a combo-box in WPF. If you only want to display some text use a TextBlock instead. Both KEP and I are interested in what you mean by a 'read-only' combobox
Member 11603144 5-Jun-15 0:18am    
I have a Combo box, and its IsEditable="Falase". also it contain some list items.
I need to set a default value in combo box and it should display as the default of the UI load, and not include the default value in combo box list item.
CHill60 7-Jun-15 17:41pm    
You may need to "insert" some text, but this sounds a little weird to be honest. You might be better off trying explain (in detail) what you are trying to achieve from your "users" perspective. Are you trying to do something like "Choose a Value" being displayed, then then "choose a value" is not a valid selection?
Member 11603144 16-Jun-15 2:14am    
for eg: i have a combobox with dropdown contains 3 values"small","large","medium".
When i load the UI the comboxbox should contain a text "Select size"
I made the property "IsReadOnly=True" and It's work :D
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900