Telerik Forums
UI for WPF Forum
7 answers
189 views

I want to disable all highlight in the RadAutoCompleteBox dropdown list. So I have HighlightBehavior.FindHighlightedIndex which returns -1. But, still one item in ItemsSource is highlighted. How can I fix it?

 

FYI: On entering EACH new character in the search text box, we are calling a web service which returns a list of recommended search strings from history. (This behavior is similar to google search box.) And we set that list to ItemsSource property. This service call takes a few milliseconds.

Observation: after hitting a new character in search box, FindHighlightedIndex is called, which returns -1, and after that, our service returns a new set of strings to be set in dropdown list, and that list is set to the ItemsSource property.  

 

Kindly suggest how to fix this.

Thanks.

 

Our code snippet below:

public class NoSuggestionItemHighlightBehavior : HighlightBehavior
{
    public override int FindHighlightedIndex (string searchText, System.Collections.IList filteredItems, IEnumerable<object> escapedItems, string textSearchPath, TextSearchMode textSearchMode)
    {
       return -1;
    }
}

 

<telerik:RadAutoCompleteBox x:Name="textBox_Search"
ItemsSource="{Binding AutoCompleteList}"
SelectionMode="Single"
TextSearchMode="Contains"
BorderThickness="0"
HighlightBehavior="{StaticResource NoSuggestionItemHighlightBehavior}"
SearchText="{Binding SearchText, Mode=TwoWay}">

Dinko | Tech Support Engineer
Telerik team
 answered on 18 Oct 2019
3 answers
493 views

Have a bit of an odd situation. I have two AutoCompleteBoxes. Both are bound are in a near-identical manner, the only difference being that the 2nd one is bound to a filtered view of the data bound to the 1st box:

Box 1: ItemsSource="{Binding SearchRecords}" DisplayMemberPath="SearchValue" SelectedItem="{Binding SearchBox1SelectedItem, Mode=TwoWay}"

Box 2: ItemsSource="{Binding SearchRecords2View}" DisplayMemberPath="SearchValue" SelectedItem="{Binding SearchBox2SelectedItem, Mode=TwoWay}"

After the second selection is made, I take some query actions, which work correctly. I then attempt to blank both boxes to clear the slate for the next user action:

SearchBox1SelectedItem = null;
SearchBox2SelectedItem = null;

Both property setters handle this in the same way:

if (_searchBox1SelectedItem != value)
                {
                    _searchBox1SelectedItem = value;
                    RaisePropertyChanged();
                }

 if (_searchBox2SelectedItem != value)
                {
                    _searchBox2SelectedItem = value;
                    RaisePropertyChanged();
                }

The effect on the SearchBox1 is as expected, i.e. the box clears itself, as shown in its properties as per AutoCompleteBox1.jpg, attached.

But this does not happen as expected for SearchBox2. Instead, it seems to have made an aborted attempt to clear itself, as per AutoCompleteBox2.jpg. Note how the SelectedItem value for SearchBox2 has been nullified, as intended, but it retains 1 record in its SelectedItems list, and also note how its SearchText, which is set to "Bil", should in fact be "Billy Joel", which is what still appears in the Search Box.

Any ideas?

 

Vladimir Stoyanov
Telerik team
 answered on 13 Sep 2019
1 answer
194 views

I have a RadGridView, in the first column is an AutoCompleteBox for searching names. I will search name and paste in to the same column. 

I have build the AutoCompleteBox in RadgridView.CellEditTemplate like this:

 

<telerik:RadAutoCompleteBox DisplayMemberPath="Name"
                                                        TextSearchMode="Contains"
                                                        TextSearchPath="Name"
                                                        SearchText="{Binding Path=Name, Mode=TwoWay}"
                                                        AutoCompleteMode="Suggest"
                                                        SelectionMode="Single"     
                                                        BoxesItemStyle="{StaticResource RadAutoCompleteBoxStyle}"
                                                        NoResultsContentTemplate="{StaticResource RadAutoCompleteBoxNoResultsContentTemplate}"
                                                        NoResultsContent="{x:Static resources:Translations.lbl_NoMatches}"
                                                        ItemsSource="{Binding Path=DataContext.Project.Customers, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}">

 

But i always get error "System.Windows.Data Error: 26 : ItemTemplate and ItemTemplateSelector are ignored for items already of the ItemsControl's container type; Type='RadWatermarkTextBox'", if i type in the column. DisplayMemberPath="Name" and SearchText="{Binding Path=Name, Mode=TwoWay}" ara in conflict. Can sameone help me?

 

Thanks in advance.

 

Martin Ivanov
Telerik team
 answered on 19 Aug 2019
2 answers
647 views

Hi,

I'm running into some problems applying new style & template settings to AutoCompleteBox.

I've read this article: https://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-editing-control-templates,and I've created a simple default Telerik application that has only an AutoCompleteBox defined:

<Window x:Class="TelerikWpfApp1.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="350" Width="525">
        <Grid>
            <telerik:RadAutoCompleteBox />   
        </Grid>
</Window>

If I use VS to generate a copy of the required template (i.e. right-click the RadAutoCompleteBox, Edit Template ->Edit a Copy..., etc., I get this error message:

InvalidCastException: [A]Telerik.Windows.Controls.RadListBox cannot be cast to [B]Telerik.Windows.Controls.RadListBox. Type A originates from 'Telerik.Windows.Controls, Version=2019.2.618.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' in the context 'LoadNeither' at location 'C:\Users\WWill\AppData\Local\Microsoft\VisualStudio\16.0_789bb273\Designer\ShadowCache\gmfvgqnw.h3w\4sct5rze.jm2\Telerik.Windows.Controls.dll'. Type B originates from 'Telerik.Windows.Controls, Version=2019.2.618.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' in the context 'LoadFrom' at location 'C:\Program Files (x86)\Progress\Telerik UI for WPF R2 2019\Binaries\WPFRadF45\Telerik.Windows.Controls.dll'.

If, instead, I open the Telerik.Windows.Controls.Input.xaml file and copy the relevant RadAutoCompleteBox styles/templates into a resource dictionary in my application, I find a great many dependencies on other definitions in that file, which triggers a lot of "not found" reference errors.

So, I copied the entire ResourceDictionary from that file into my test app. Not too happy about copying 7,500 lines of code anywhere, but, hey, I'll try anything once. Unfortunately, I'm still getting errors, this time 28 of them in the form:

Severity Code Description Project File Line Suppression State
Error XDG0044 The local property "Columns" can only be applied to types that are derived from "RadUniformGrid". TelerikWpfApp1 App.xaml 5334 

As these did not stop me from building/running my app, I proceeded to modify my RadAutoCompleteBox definition as follows:

<telerik:RadAutoCompleteBox TextBoxStyle="{DynamicResource RadAutoCompleteTextBoxStyle}"/> 

This resulted in the following message:

InvalidOperationException: 'RadWatermarkTextBox' TargetType does not match type of element 'RadWatermarkTextBox'.

Again, this error doesn't stop me from compiling/running the app, but I thought I'd mention it in case it's an indicator

Finally, despite all the aforementioned errors, I am able to tweak the appearance of my RadAutoCompleteBox control, but I'm not feeling too good about it, as it seems like a very inelegant way to achieve a few visual tweaks.

Any advice for a newbie?

Wayne

 

 

n/a
Top achievements
Rank 1
 answered on 14 Aug 2019
2 answers
159 views

Why is performance so good for this control? I'm loading 23,000 search items into an ObservableCollection, and search response is almost instantaneous.

This may seem like an odd question, but in preparing to work with this control, I found a few online complaints about performance and a suggestion to trigger virtualization by setting the MaxHeight property of the inner ListBox, as follows:

<Style x:Key="AutoCompleteBoxStyle" TargetType="{x:Type toolkit:AutoCompleteBox}">
    <Style.Resources>
        <Style TargetType="{x:Type ListBox}">
            <Setter Property="MaxHeight" Value="200" />
        </Style>
    </Style.Resources>
</Style>

I found that this wasn't necessary, and as I hate mysteries, I'm wondering if Telerik has taken care of all performance issues (say by automatically triggering virtualization) since the time of the complaints.

If this isn't the case, and I can expect to run into performance problems with a larger number of search items, are there any standard techniques to address such eventual problems?

Wayne

n/a
Top achievements
Rank 1
 answered on 14 Aug 2019
3 answers
161 views

Hello,

On an AutoCompleteBox, :

- MultipleMode : The selection have a border and a close button. It's really easy to remove the selection. But the number of selection is not limited.

- SingleMode : The selection have no border and close button.

Is it possible to have SingleMode with the border and the close button ? Or is it possible to limit the selection quantity of MultipleMode to 1 ?

Best regards

Philippe

Vladimir Stoyanov
Telerik team
 answered on 05 Aug 2019
3 answers
666 views
Hello,
I have a RadAutocompleteBox and I'm looking for a way to select all text on focus.
I looked for SelectAll() method but there's not one. Is there a way to do this?

Thank you in advance
Best regards
Fabio
Dilyan Traykov
Telerik team
 answered on 24 Jul 2019
1 answer
101 views
Is it possible to allow only list entries for the RadAutoCompleteBox? As Items Source I have bound an ObservableCollection.
Harald
Top achievements
Rank 2
 answered on 14 Jul 2019
2 answers
1.2K+ views

Hi,

I create UI tests for our WPF Desktop App.
For this I use the WinAppDriver from Microsoft.
Everything works fine, excepting "SendKeys" to AutoCompleteBox.

 

m_session.FindElementByAccessibilityId("AutoComlpleteBoxID").Click();   // Works ... I see the input cursor inside the box

m_session.FindElementByAccessibilityId("AutoComlpleteBoxID").SendKeys("12345"); // Works not !

Exception:
An unknown error occurred in the remote end while processing the command.

Any Idea why it happens.
With a standard WPF textbox it works.

Regards
Stefan

Vladimir Stoyanov
Telerik team
 answered on 19 Jun 2019
4 answers
243 views

This control has been working fine until today, but now it cannot be displayed for some reason.  This occurred after I added an empty WPF Custom Control Library project to the solution, which I have since removed...

 

The element "acbSelectPerson" could not be displayed because of a problem with Telerik.Controls.RadAutoCompleteBox:

InvalidCastException:

[A]Telerik.Windows.Controls.RadListBox cannot be cast to [B]Telerik.Windows.Controls.RadListBox. Type A originates from 'Telerik.Windows.Controls, Version=2016.2.613.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' in the context 'LoadFrom' at location 'C:\Program Files (x86)\Telerik\UI for WPF Q2 2016\Binaries\WPF45\Telerik.Windows.Controls.dll'. Type B originates from 'Telerik.Windows.Controls, Version=2016.2.613.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' in the context 'LoadNeither' at location 'C:\Users\000105261\AppData\Local\Microsoft\VisualStudio\14.0\Designer\ShadowCache\13qxpo3c.c3s\4xmqqihl.1si\Telerik.Windows.Controls.dll'.

Stack Trace:

   at Telerik.Windows.Controls.RadAutoCompleteBox.InitializeItemsControlPart()
   at Telerik.Windows.Controls.RadAutoCompleteBox.OnApplyTemplate()
   at System.Windows.FrameworkElement.ApplyTemplate()
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)

Magdalena
Top achievements
Rank 1
 answered on 03 Jun 2019
Narrow your results
Selected tags
Tags
+112 more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?