Reputation: 1663
Say I have a ComboBox which has an array of doubles as the ItemsSource. In that array are the numbers "1.0" and "2.5". If I change the SelectedValue to "3.0" the ComboBox goes blank. How do I get the ComboBox to display "3.0" without having to add it to the list of possible values that would appear in the drop-down box?
I guess what I'm really asking is do I need some sort of customised combobox to display an item that is not in the drop down list?
Upvotes: 0
Views: 492
Reputation: 69959
The simplest (but not best) way to achieve your requirements (gathered from the comments because you didn't explain them properly in your question) is to add a TextBlock
in front of your ComboBox
:
<Grid>
<ComboBox ItemsSource="{Binding Items}" ... />
<TextBlock Text="{Binding Output} Visibility="{Binding IsOutputVisible, Converter=
{StaticResource BooleanToVisbilityConverter}}" />
</Grid>
You could then add a bool IsOutputVisible
property to make it visible or hide it whenever you need to... you'd need to use a BooleanToVisbilityConverter
to make this work.
Upvotes: 1