Devexpress ComboEdit Focus to options by text - wpf

I am using ComboBoxEdit of DevExpress like this:
<dxe:ComboBoxEdit Grid.Column="1" Grid.Row="1" SelectedIndex="0" EditValue="{Binding conti_cd, UpdateSourceTrigger=PropertyChanged}" SelectedIndexChanged="cboRegion_SelectedIndexChanged" ShowSizeGrip="False" x:Name="cboRegion"/>
Now, I donot allow user input text to this combox but, I wanna select options in ComboBox by text.
Example:
I have a combobox like above.
When I type "E" the combobox will focus to "EUROPE" options.
I tried to research but I don't know how to do.
Please give me some suggestion.

I found the solution by myself.
Just set AutoComplete = true;
Full code should be like this:
<dxe:ComboBoxEdit Grid.Column="1" Grid.Row="1" SelectedIndex="0" EditValue="{Binding conti_cd, UpdateSourceTrigger=PropertyChanged}" SelectedIndexChanged="cboRegion_SelectedIndexChanged" ShowSizeGrip="False" x:Name="cboRegion" AutoComplete="true"/>
And if someone get the trouble like me, please read below comment:
If the AutoComplete property is set to true, the text typed by an
end-user within the edit box is automatically completed, if it matches
a value displayed within the dropdown. By default, the AutoComplete
option is disabled for ComboBoxEdit, and enabled for LookUpEdit.
The Auto-Complete feature is not supported if the combobox editor's
popup window is represented by a check box list.

Related

Combobox: Get text and selected item in mvvm way

The combobox is editable so user can also write. I have two usecases:
Get the text from combobox in a Lostfocus way, when user writes
something in the box and when he presses "Tab" then I want the text
from the combobox and I add the value in the itemsSource list.
When the users makes the selection from the combobox dropdown, I want that
selected item as soon he selects it and this time I dont
want to have it in Lostfocus manner but somewhat like
PropertyChanged way.
I tried the code which is given below:
<ComboBox Margin="3" x:Name="Combobox" SelectedItem="{Binding SelectedPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Text="{Binding PathLocation, UpdateSourceTrigger=LostFocus, ValidatesOnNotifyDataErrors=True}" IsTextSearchEnabled="True" VerticalContentAlignment="Center" ItemsSource="{Binding SelectedPaths}" IsEditable="True" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch"/>
Things worked fine for the first time when the application starts but after some interactions the problem arises. When the user starts typing in the combobox the SelectedItem property of combobox triggers which is contrary to what I want in the first use case.
In short: when the user writes something in the combobox I want to have it in a Lostfocus manner and when he makes the selection from the dropdown of combobox I want to have it in a PropertyChanged manner.
Let me know if more details are required.
I removed the "IsTextSearchEnabled" property but it also didnt work then I came to know that "IsTextSearchEnabled" property of Comobobox is by default true, which is causing some values suggested by the combobox are setting in my properties. As soon as I made the "IsTextSearchEnabled" to false, it is working fine.

WPF ComboBox is not collapsing dropdown once it loses focus

I have a very strange situation. I have ComboBox which is loaded with some items. When I click on it, the drop-down expands showing all items.
If I now open another application such as Notepad, the dropdown will not collapse which I would expect to happen. As a result, any overlapping application, such as opened Notepad, will appear as being located in between the WPF hosting the ComboBox and the ComboBox drop-down like on screenshot below. Probably the z-order is somehow totally wrong.
I believe the reason for this behavior is the fact that the dropdown did not collapse at the first place. My ComboBox is part of a Usercontrol and its xaml is like:
<ComboBox ItemsSource="{Binding ValueSet}"
SelectedItem="{Binding SelectedNode}"
DisplayMemberPath="Name"
BorderBrush="Green"
BorderThickness="1" SelectionChanged="ComboBox_SelectionChanged">
</ComboBox>
In my opinion there is no any problem with the z-order in your xaml. The actual problem is in the ComboBox template in your application. You should find the actual style(or control template) your Combo is based on and check the Popup(usually named "PART_Popup") control inside that control template. The IsOpen property of the Popup should be bound to the ComboBox IsDropDownOpened property, like that:
`IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"`
Any way you should search the solution for your problem in incorrect control template of the Combo control. There is something that make it be opened(probably by making the IsOpen property of the inner Popup control to be always true). Let me know if it you need more suggestion.

RadComboBox selects first item on Textchanged

I have a radcombobox which is TextSearchEnabled and Editable. The issue is whenever there is a textchanged it automatically selects the first item that is matched and that actually filters out the other dropdown which i wanted to restrict it.
Is there anyway i can restrict this behavior and only update the selected item on lost focus.
<telerik:RadComboBox x:Name="ComboBox"
ItemsSource="{Binding Users}"
SelectAllTextEvent="GotFocus"
IsTextSearchEnabled="True"
IsEditable="True"
telerik:TextSearch.TextPath="FullName"
IsFilteringEnabled="True"
SelectedItem="{Binding SelectedUser}"
TextSearchMode="Contains"
MinWidth="80"
DisplayMemberPath="FullName"/>
I got the answer from telerik forum where i posted the same question. So here i am answering it on my own.
ANSWER:
In order to disable the auto selection of items in the RadComboBox
control all you need to do is set its CanAutocompleteSelectItems
property to False.
Here's the link to forum:
http://www.telerik.com/community/forums/wpf/combobox/radcombobox-selects-first-item-on-textchanged.aspx

Set WPF CheckBox in a ComboBox to Checked

I have a custom WPF control - essentially a combo-box with check-boxes. The combo-boxes are successfully bound to a list of available items.
This control is to represent a field on a form. It is possible for the form to be completed already, in which case, the control must be rendered with the selected items - i.e. any items previously selected must be rendered as a checked CheckBox; it is here I'm running into trouble.
My first thought was to simply bind the IsChecked property - I don't think this can be done as the list of currently-selected-items is different from the list of available items which the ComboBox is bound to.
Basically, how do I gain access to the CheckBox object to set the Checked property to true? I've looked into this extensively and I can't fathom this out.
I'm using the ItemContainerGenerator approach - so when the user clicks on the drop-down, it is intended that a handler will iterate through the CheckBoxes and set the relevant boxes to checked.
Here's the XAML:
<ComboBox x:Name="FieldOptions"
ItemsSource="{Binding}"
HorizontalAlignment="Stretch"
Height="30"
KeyDown="FieldOptions_OnKeyDown">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Name="checkbox"
Content="{Binding Path=Text}"
Uid="{Binding Path=ID}"
FontStyle="Normal"
Foreground="Black"
Checked="CheckBox_OnChecked" />
</DataTemplate>
</ComboBox.ItemTemplate>
Any thoughts would be much appreciated.

Radcombobox clears the text when it is not in the items list

I have a telerik's radcombobox like below:
<telerik:RadComboBox x:Name="cbCustomerName"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="3"
Margin="0 0 0 10"
DisplayMemberPath="FullName"
IsEditable="True"
IsFilteringEnabled="True"
ItemsSource="{Binding Customers}"
OpenDropDownOnFocus="True"
SelectedValuePath="CustomerId"
SelectionChanged="cbCustomerName_SelectionChanged"
Text="{Binding CurrentCustomer.FullName,
UpdateSourceTrigger=LostFocus}" />
When I type something in the textbox that is not in its items list and then go to some other control, it clears the text in it, which I don't want.
I have checked all properties and couldn't find anything to retain it after losing focus.
Please help if anyone knows about this.
I know this question is old but I figured I'd post a solution in case anyone else has this issue. If you set the "IsTextSearchEnabled" property to "False", it allows custom text and doesn't clear it when the RadComboBox loses focus.
Have you tried using the AllowCustomText Property to true?
Try adding TextSearchMode="Contains". Either that or try removing IsFilteringEnabled="True" if you do not need to filter your results.
I am not 100% sure, but it may clear your text if you try and filter it and it does not find anything.

Resources