Hi Guys,
I'm using RadAutocompleteBox from RadControls for WPF Q3 2012 in an MVVM Application.
Here is sample code:
The SelectedItem is bound to an MVVM ViewModel.
My problem is when I want to clear the text displayed in the autocomplete's textbox by setting the ViewModel.ImpactedLocation = null;
the selectedItem is cleared, but the text displayed is still here.
How can I clear it please? Something's to do with the SearchText? (try to clear it too, but still not working)
Thank's for your help.
Kind regards,
JC
I'm using RadAutocompleteBox from RadControls for WPF Q3 2012 in an MVVM Application.
Here is sample code:
<
Controls:AutoCompleteBox
WatermarkContent
=
"Select a location..."
DisplayMemberPath
=
"Name"
TextSearchPath
=
"Name"
SelectedItem
=
"{Binding ImpactedLocation, Mode=TwoWay, ValidatesOnDataErrors=True}"
ItemsSource
=
"{Binding AvailableImpactedLocations}"
IsEnabled
=
"{Binding IsOpened}"
MaxDropDownHeight
=
"400"
DropDownWidth
=
"400"
/>
My problem is when I want to clear the text displayed in the autocomplete's textbox by setting the ViewModel.ImpactedLocation = null;
the selectedItem is cleared, but the text displayed is still here.
How can I clear it please? Something's to do with the SearchText? (try to clear it too, but still not working)
Thank's for your help.
Kind regards,
JC
7 Answers, 1 is accepted
0
Hello JC,
Usually setting the SearchText to String.Empty should work. I am attaching a simple project and a video showing how it behaves on my machine. It would be great if you can check it and see if we don't differ in something. If that is the case a simple project or editing the attached one would be very helpful.
Hope this will help.
Greetings,
Georgi
the Telerik team
Usually setting the SearchText to String.Empty should work. I am attaching a simple project and a video showing how it behaves on my machine. It would be great if you can check it and see if we don't differ in something. If that is the case a simple project or editing the attached one would be very helpful.
Hope this will help.
Greetings,
Georgi
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Gabriel
Top achievements
Rank 1
answered on 18 Jul 2013, 01:13 PM
Hi Georgi, sorry my bad english, I have a same problem of another guy, I use MVVM too, to reproduce the error, change your sample to load like this:
public MainWindow()
{
InitializeComponent();
var vm = new ViewModel();
vm.MySelectedItem = vm.Collection[0];
this.DataContext = vm;
}
In my modification, the behavior is like o MVVM work, load a value of a collection to current item....
The big problem, in the control how set the value of selected item programmatically the property "SearchText" was empty...
My solution was get the value of property by reflection in Load of AutoCompleteBox, , like down, if exists a better solution please notify...
if
(SelectedItem !=
null
)
{
var property = SelectedItem.GetType().GetProperty(TextSearchPath.ToString());
if
(property !=
null
)
{
var value = property.GetValue(SelectedItem,
null
);
if
(value !=
null
)
AutoCompleteBox1.SearchText = value.ToString();
}
}
else
{
AutoCompleteBox1.SearchText =
string
.Empty;
}
0
Hi Gabriel,
We were able to reproduce the issue and we are glad to inform you that it is fixed in our latest versions of the controls. Also I can't think of any better workaround than the one you have provided.
So It would be great if you can try our fix and let us know if everything works as expected.
Regards,
Georgi
Telerik
We were able to reproduce the issue and we are glad to inform you that it is fixed in our latest versions of the controls. Also I can't think of any better workaround than the one you have provided.
So It would be great if you can try our fix and let us know if everything works as expected.
Regards,
Georgi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Marc
Top achievements
Rank 1
answered on 03 Oct 2013, 01:12 AM
Hi Georgi, we have run across the same problem using Version 2013.2.724.45. Which version has this fix?
0
Hi Marc,
We have marked the issue as fixed since Q2 2013 (2013.2.611) and the fix is available in the 2013.2.724.45 also.
We have retested it, but it seems like it works at our end. I am attaching my test application, it would be great if you can check it out and let me know what am I missing.
Also any info that could help reproducing it would be helpful.
Regards,
Georgi
Telerik
We have marked the issue as fixed since Q2 2013 (2013.2.611) and the fix is available in the 2013.2.724.45 also.
We have retested it, but it seems like it works at our end. I am attaching my test application, it would be great if you can check it out and let me know what am I missing.
Also any info that could help reproducing it would be helpful.
Regards,
Georgi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Marc
Top achievements
Rank 1
answered on 07 Oct 2013, 11:27 PM
Hi Georgi, I tried this demo and it worked as desired in most cases. I have narrowed down our issue to the LostFocus and LostKeyboardFocus events.
This method will coerce the SelectedItem to be the previous valid result if SearchText is not empty and not valid when losing focus.
The problem is that in some cases LostFocus / LostKeyboardFocus fire unexpectedly.
Type any single number into the AutoCompleteBox and click an item in the list. The Item will be selected as expected and LostFocus will not fire. Do this as many times as you wish, it will consistently reproduce the desired effect.
Type into the box so that there is only one selection available and click the item. LostFocus will fire triggering the coersion, this is not expected nor desired. This is consistently reproducible.
void
AutoComplete_OnLostKeyboardFocus(
object
sender, KeyboardFocusChangedEventArgs e)
{
if
(autoComplete.SelectedItem ==
null
&& !
string
.IsNullOrEmpty(autoComplete.SearchText))
{
autoComplete.SelectedItem = ((ViewModel) DataContext).LastItem;
}
}
This method will coerce the SelectedItem to be the previous valid result if SearchText is not empty and not valid when losing focus.
The problem is that in some cases LostFocus / LostKeyboardFocus fire unexpectedly.
Type any single number into the AutoCompleteBox and click an item in the list. The Item will be selected as expected and LostFocus will not fire. Do this as many times as you wish, it will consistently reproduce the desired effect.
Type into the box so that there is only one selection available and click the item. LostFocus will fire triggering the coersion, this is not expected nor desired. This is consistently reproducible.
0
Hi Marc,
Thanks to your help we were able to reproduce the described behavior. It seems like that the actual issue is that the LostFocus events are firing as they should not when the item is selected. So we have logged the issue here in our Public Issue Tracking System, where you can track its progress.
Regards,
Georgi
Telerik
Thanks to your help we were able to reproduce the described behavior. It seems like that the actual issue is that the LostFocus events are firing as they should not when the item is selected. So we have logged the issue here in our Public Issue Tracking System, where you can track its progress.
Please, excuse us for the inconvenience. We have added points to your account for the report.
Regards,
Georgi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>