Hi,
how do I change the UpdateSourceTrigger of the SelectedItem? Right now the SelectedItem changes only if the user hits the enter key, but I would like the SelectedItem to change after every keystroke.
This is my current code:
<ig:XamComboEditor AllowFiltering="True" ItemsSource="{Binding AccountingFieldContainer.ActiveItems}" CustomValueEnteredAction="True" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Loaded="XamComboEditor_Loaded" DisplayMemberPath="DisplayName" IsEditable="True"> <ig:XamComboEditor.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding DisplayName}" /> </DataTemplate> </ig:XamComboEditor.ItemTemplate> </ig:XamComboEditor>
The Loaded event handler adds a custom items filter to the editor.
All ideas are appreciated.
Darius
Hello Darius,
Can you expand on your requirement a bit more? What keystrokes are you referring to? When the user types the value into the combobox to filter the items by, or when the user uses the arrow keys to cycle through the items in the dropdown? Maybe you can provide a scenario using this requirement to help me better understand what you are looking for.
Hello Rob,
I want to use the editor to either let the user choose one item from the dropdown or to create a new item (The new item shouldn't be included in the items list. CustomValueEntered="Allow"). I also want to allow filtering with a custom items filter.
My scenario:
User starts to type in a string into the editor. During this operation the custom items filter, filters the selectable items. The selected item is either a matching item from the selected items (100% match) or a new instance of an item, that holds the typed in string in its property that is set in the DisplayMemberPath (in this example DisplayName).
Basicaly this functionality is already included in the editor, with one exception. The selected item changes only if
But what I also need is, that the SelectedItem changes if the LostFocus event occures.
Yours sincerely,
It's a little weird to set the SelectedItem on the XamComboEditor to an item that isn't in the XamComboEditor but this is definitely something you can do. You can listen for the TextChanged event on the TextBox inside the XamComboEditor and use this to check if the typed value matches anything inside the list. If it does then you can set the SelectedItem at that moment but if it doesn't you can create a new instance of an item and assign it to the SelectedItem. I've attached a sample that demonstrates this.
Let me know if you have any questions on this.
Let me know if you have any further questions on this.
Hi.
First of all thank you for your example and sorry for my late reply. I have changed the workflow in my application and I don't need to listen for every keystroke anymore. Now I just need to get the current selected item if the "Enter" or "Return" key has been pressed. This works perfectly if CustomValueEnteredAction is set to ignore.
In my case I want CustomValueEnteredAction to be set to Allow. If I now type in some custom values (e.g. "aaaa") and press "Enter" or "Return" the SelectedItem Property is set correct to a new Item object which contains "aaaa" in its DisplayName property. But if I now continue typing e.g. another "a" I receive an "ArgumentOutOfRangeException" with this Stacktrace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException() at System.Collections.ObjectModel.Collection`1.RemoveAt(Int32 index) at Infragistics.Controls.Editors.ComboEditorBase`2.SelectedItems_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index) at System.Collections.ObjectModel.Collection`1.Remove(T item) at Infragistics.Controls.Editors.ComboEditorBase`2.ValidateSelection(String text) at Infragistics.Controls.Editors.ComboEditorBase`2.ProcessEditorText(Boolean allowDropDown, Boolean attemptAutoComplete) at Infragistics.Controls.Editors.ComboEditorBase`2.DelayTracker_Tick(Object sender, EventArgs e) at System.Windows.Threading.DispatcherTimer.FireTick(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at XamComboEditorTest.App.Main() in c:\Users\dgeiss\Documents\Visual Studio 2012\Projects\XamComboEditorTest\XamComboEditorTest\obj\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
How can I solve this?
Btw: I have changed your Solution and attached it.
I was able to reproduce your issue running the sample against the 14.1 assemblies. As such I have created a private case for you and I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 171008. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
Your case number is CAS-135143-H4K1P4. The case has been linked to the development issue so that you may view the status of it. You can view your private case here: https://ko.infragistics.com/my-account/support-activity