<StackLayout VerticalOptions="Start"
HorizontalOptions="Start"
Padding="30">
<autocomplete:SfAutoComplete x:Name="autoComplete"
HeightRequest="40"
AutoCompleteMode="Suggest"
SuggestionMode="Custom"
IgnoreDiacritic="False">
<autocomplete:SfAutoComplete.AutoCompleteSource>
<ListCollection:List x:TypeArguments="x:String">
<x:String>Łogan</x:String>
<x:String>Łuke</x:String>
<x:String>Łevi</x:String>
<x:String>Łucas</x:String>
<x:String>Ĺily</x:String>
<x:String>Ałdan</x:String>
<x:String>Ałdrin</x:String>
<x:String>Ałan</x:String>
</ListCollection:List>
</autocomplete:SfAutoComplete.AutoCompleteSource>
</autocomplete:SfAutoComplete>
</StackLayout> |
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
autoComplete.Filter = ContainingIgnoreDiacritic;
}
public bool ContainingIgnoreDiacritic(string search, object item)
{
if (item != null)
{
string text = item.ToString().ToLower();
try
{
string suggestionItem = Encoding.ASCII.GetString(
Encoding.GetEncoding("ISO-8859-1").GetBytes(text)
);
string searchText = Encoding.ASCII.GetString(
Encoding.GetEncoding("ISO-8859-1").GetBytes(search)
);
if (suggestionItem.Contains(searchText.ToLower()))
{
return true;
}
else
{
return false;
}
return true;
}
catch (Exception)
{
return (text.Contains(search));
}
}
else
{
return false;
}
}
} |