<ContentPage.BindingContext>
<local:EmployeeViewModel/>
</ContentPage.BindingContext>
<StackLayout VerticalOptions="Center">
<local:CustomAutoComplete x:Name="autoComplete" VerticalOptions="Center" Watermark="Start typing"
HeightRequest="40" SuggestionBoxPlacement="Top"
DisplayMemberPath="Name" MaximumDropDownHeight="300"/>
</StackLayout> |
public class CustomAutoComplete : SfAutoComplete
{
} |
[assembly: ExportRenderer(typeof(CustomAutoComplete), typeof(AutoCompleteRenderer))]
namespace AutoCompleteSample.Droid
{
public class AutoCompleteRenderer : SfAutoCompleteRenderer
{
SfAutoComplete FormsComboBox;
public AutoCompleteRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Syncfusion.SfAutoComplete.XForms.SfAutoComplete> e)
{
base.OnElementChanged(e);
if (Control != null)
{
FormsComboBox = e.NewElement;
Control.TextChanged += Control_TextChanged;
}
}
private void Control_TextChanged(object sender, Com.Syncfusion.Autocomplete.TextChangedEventArgs e)
{
if (FormsComboBox.DataSource == null)
FormsComboBox.DataSource = (FormsComboBox.BindingContext as EmployeeViewModel).EmployeeCollection;
}
}
} |
<autocomplete:SfAutoComplete x:Name="autoComplete" VerticalOptions="Center" Watermark="Start typing" ValueChanged="AutoComplete_ValueChanged"
HeightRequest="40" SuggestionBoxPlacement="Top"
DisplayMemberPath="Name" MaximumDropDownHeight="300"/> |
private void AutoComplete_ValueChanged(object sender, Syncfusion.SfAutoComplete.XForms.ValueChangedEventArgs e)
{
if (autoComplete.DataSource == null)
autoComplete.DataSource = (autoComplete.BindingContext as EmployeeViewModel).EmployeeCollection;
} |
Device.BeginInvokeOnMainThread(async () =>
{ //Do your action }); |
<autocomplete:SfAutoComplete HeightRequest="40" DropDownFooterViewHeight="60" ShowDropDownFooterView="True" Watermark="Enter title" NoResultsFoundText="No Results" x:Name="autoComplete" DisplayMemberPath="title" ValueChanged="AutoComplete_ValueChanged">
<autocomplete:SfAutoComplete.DropDownFooterView>
<Grid VerticalOptions="StartAndExpand" HeightRequest="60" BackgroundColor="#f0f0f0" >
<busyIndicator:SfBusyIndicator VerticalOptions="Start" x:Name="busyindicator"
AnimationType="SlicedCircle"
ViewBoxWidth = "40"
ViewBoxHeight="40"
TextColor="Maroon"
IsBusy="True"/>
</Grid>
</autocomplete:SfAutoComplete.DropDownFooterView>
</autocomplete:SfAutoComplete> |
private void AutoComplete_ValueChanged(object sender, Syncfusion.SfAutoComplete.XForms.ValueChangedEventArgs e)
{
if (autoComplete.DataSource == null)
{
DataChanged();
}
}
public async void DataChanged()
{
…
if (autoComplete.DataSource == null)
{
await Task.Delay(4000);
busyindicator.IsBusy = false;
autoComplete.DropDownFooterViewHeight = 0;
autoComplete.DataSource = Items;
}
}
|
Hi Benjamin,
Thanks for your update.We have analyzed the reported exception it seems as below mentioned forum discussion that exception it occurs some cases while using async method to get data from database. We would like to let you know that is not related with our control. To resolve this, please use the as below code snippet
Device.BeginInvokeOnMainThread(async () =>
{
//Do your action});Since we do not know the exact scenario of your case, can you update complete code snippet or modified sample with the reported issue which will be helpful for us to investigate more about and provide better solution at the earliest.Regards,Hemalatha M.