RadComboBox selects first item on Textchanged - wpf

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

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.

Which tool is the best option for doing search in Datagrid in wpf?

I have created search option using combobox, for example
In combobox1 items are m1,m2,m3,m4,m5 based on that, if m1 item selected then
another combobox2 displays with items a,b,c,d and if a item is selected another
combobox3 dispalys, based on last combobox it searches on the datagrid.
I think it is long process, use of many combobox makes it lenghty. Is any
other way is their to implement this. plz help
<ComboBox Grid.Column="1"
Grid.Row="1"
x:Name="cmbType"
VerticalAlignment="Top"
IsEnabled="{Binding IsOther}"
ItemsSource="{Binding Source={StaticResource enumTypeOfType}}"
SelectedItem="{Binding SearchType,Mode=TwoWay}"
SelectedIndex="{Binding CmdResIndex,Mode=TwoWay}"
IsSynchronizedWithCurrentItem="True"
SelectionChanged="DataSource1"
Margin="0,0,1,0">
</ComboBox>
So if i get this right, you have a collection a, which goes to collection b,etc, and the second collection will change based on the selected item of the first? You have to remember, that since the data will change for each selection, hard coding the value is out of the question.
Knowing this, WPF provides you with a great mechanism for this. Using a stackpanel, with a list view will actually work.
<ItemsControl ItemsSource="{binding collections}" ItemTemplate="{binding TemplateForListViewItems}" ItemPanelTemplate="{binding itemPanelTemplate}"></ItemsControl>
Now, with the items control, one can simply set an ItemTemplate/DataTemplate, to set the styling of each control. Linking to the onclick event, or using interactions, you can simply do collections.Add to add your new list view with generated data for the selection, and done.

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.

How to use update source trigger on Wpf Combobox which is editable?

I have a combo box (in my wpf-mvvm app). I have set IsEditable = true. But the "property changed event" is getting fired when I start typing.
How can I set UpdateSourceTrigger = Propertychanged here ?
Also..I need to call a validation function if user has entered new value ( i mean other than those available in list ..using edit functionality).
Any help will be appreciated.
<ComboBox ItemsSource="{Binding Path = PlanTypeBasedContractNumberList }" Width="90" IsEditable="True"
SelectedValue="{Binding GeneralCharacteristicsDataContext.ContractNumber.Value}">
</ComboBox>
In an editable ComboBox, the SelectedItem and SelectedValue properties refer to the Popup items, not the editable item. Once you start typing, the SelectedItem becomes "unselected" and that's why the event fires.
To bind to the value of the TextBox of the ComboBox, use the Text property:
<ComboBox IsEditable="True" Text="{Binding Path=..., UpdateSourceTrigger=...}">

Want to add the selectedValue also in the xaml along with the selected Text in my wpf window

I have a compbobox with the following information
<ComboBox
Margin="10,10,0,13" Name="ComboBox1" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="128" Height="21">
<ComboBoxItem Content="All " ></ComboBoxItem>
<ComboBoxItem Content="Printed"></ComboBoxItem>
<ComboBoxItem Content="Unprinted"></ComboBoxItem>
</ComboBox>
I want to also add the selected value for all being 2 printed being 1 and unprinted being 0 is there a way to add it in the xaml?
If you reversed the order of your ComboBoxItem declarations, then the property SelectedIndex on the ComboBox would yield these results.
Though its not a very scalable solution. You might want to try creating a collection of enumerated types and then binding that to the ItemsSource of the ComboBox and then investigating the SelectedItem to see which item has been selected.
Hope it helps.
I think I found the answer
Selected Value will then work because it will retrieve whatever is in Tag of the selected item.

Resources