Closed Coloris closed 6 years ago
PersistentSearch
is a very special use case of an autocomplete. It is not meant to handle generic output. So I am thinking of implementing another control as a generic autocomplete. Many months ago, I implemented one for a private app. However, the user interface was quite tricky. I might start to migrate the code into this open source library.
That would be awesome ! WPF Toolkit Autocompletebox is kinda outdated and a real pain to style.
Thanks again for your work
I'vet tried your current Autocomplete control, so far it looks good ! Would you provide a way to make it look a bit smaller (if you compare it with the size of a combobox or of an expander it does not really fit overall) ?
@Coloris I extended the API and the templates to enable sizing. Applying the style MaterialDesignAutocompleteDense
will render a compact Autocomplete
. Furthermore, you can play with the FontSize
, Padding
and ClearIconSize
properties and your item template to get the perfect size.
Please let me know if the changes fit your needs.
@spiegelp The compact version of AutoComplete is perfect ! I'm in the process of implementing it as a replacement of the Wpf Toolkit autocompletebox.
Here are some possible suggestions that I think would improve this control :
<materialDesign:HintAssist.Hint>
<StackPanel Orientation="Horizontal" Margin="2,2,0,0">
<materialDesign:PackIcon Kind="DatabaseSearch"/>
<TextBlock>Lookup</TextBlock>
</StackPanel>
</materialDesign:HintAssist.Hint>
but it does not seem to work (or maybe there is a different way to achieve the same thing, also tried Autocomplete.Hint but it complains about not supporting StackPanel).
Some little issues :
- Setting the SelectedItem property to null does not clear the selection from the control.
I've also noticed a little bit of lag when the popup vanished after making a selection (my list contains roughly 35 values).
Thanks again for your great work.
Edit : There is no bug in fact with setting the SelectedItem property to null, the issue was on my side sorry.
What about keyboard support? Up and down keys for navigation, enter and tab for selecting the selected item or something like this. Would appreciate it đź‘Ť
Related to my previous suggestion: "Ability to decide whether or not to automatically re-open the list after clearing the selection"
I've found a buggy behavior, here is a way to reproduce it :
On a side note, I use Mahapps with MaterialDesignXaml (not for designing the controls, just the Window). Mahapps transition animation between TabItems makes it worse since the control is a bit moved, resulting in a situation where the popup end up in a different location that it should. It is related to the fact that the popup is not attached to the control (same behavior as moving the MainWindow around while leaving the popup open).
@Coloris I just handled Window.SizeChanged
and Window.LocationChanged
to relocate the Popup
. Unfortunately, Popup
does not update its location according to its PlacementTarget
. That's why I handle these window events to update the location.
Concerning animations you need to do some work on your own. You could try to listen to the LayoutUpdated
event and call the UpdatePopup
method of the Autocomplete
.
I will have a look at the TabControl
issue this week.
@spiegelp I've tried your implementation and it works pretty well except with double screen, here is how you can reproduce it :
Move the window while the popup is still open, as soon as the application appears on the second screen, the popup will remains stuck on the first screen until 50% of the MainWindow appears on the second screen (and then trigger the opposite effect of having the popup only on the second screen).
As for the TabControl issue, for now and until you work on it, I've implemented a dirty workaround to set the focus on the TabItem itself (which kind of fix my animation issue)
Thanks for your time.
Edit : Actually this issue exists even on a single screen, see attached picture.
@Coloris The issue with the tab control is a behavior of WPF. If you select a tab via mouse, WPF sets the focus to the content automatically (see here). So you need to keep your workaround.
The behavoir of the autocomplete popup is caused by WPF too. The popup of a MaterialDesignTheme combo box behaves the same. It will be never cut by screen edges:
At the moment, I don't know how to resolve the issues.
@spiegelp Thanks for the heads up!
Native WPF combobox behavior is to close the popup when the focus is lost (so for example by moving the window around) this could be another solution ?
As for the tabcontrol, what about triggering the popup only with mouse and keyboard events (like mousehover, tab etc.) and to autoclose the popup when focus is lost (just like my previous point in fact).
@Coloris I changed the behavior of the autocomplete popup with the last commit. The control loses the focus causing the popup to close. Now its behavior is more close to a combobox.
So far I've been using WPF Toolkit Autocompletebox (http://www.broculos.net/2014/04/wpf-autocompletebox-autocomplete-text.html) and was wondering if It would be possible to use the persistent search control as a replacement ?
It seems that the persistentsearch control only accepts a IList as a source, are you planning to extend it to support something like ObservableCollection of custom objects (and maybe a bunch of properties like SelectedItem, SelectedValuePath, DisplayMemberPath etc.)