Windows での SearchBar スペル チェック
このユニバーサル Windows プラットフォームプラットフォーム固有により、 SearchBar
はスペル チェック エンジンと対話できます。 添付プロパティboolean
を値に設定SearchBar.IsSpellCheckEnabled
することで、XAML で使用されます。
<ContentPage ...
xmlns:windows="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core">
<StackLayout>
<SearchBar ... windows:SearchBar.IsSpellCheckEnabled="true" />
...
</StackLayout>
</ContentPage>
または、fluent API を使用して C# から使用することもできます。
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
...
searchBar.On<Windows>().SetIsSpellCheckEnabled(true);
メソッドはSearchBar.On<Windows>
、このプラットフォーム固有の がユニバーサル Windows プラットフォームでのみ実行されるように指定します。 名前空間の メソッドはSearchBar.SetIsSpellCheckEnabled
Xamarin.Forms.PlatformConfiguration.WindowsSpecific
、スペル チェックのオンとオフを切り替えます。 さらに、 メソッドを SearchBar.SetIsSpellCheckEnabled
使用してスペル チェックを切り替えるには、 メソッドを SearchBar.GetIsSpellCheckEnabled
呼び出して、スペル チェックが有効になっているかどうかを返します。
searchBar.On<Windows>().SetIsSpellCheckEnabled(!searchBar.On<Windows>().GetIsSpellCheckEnabled());
その結果、 に SearchBar
入力されたテキストはスペル チェックが可能になり、誤ったスペルがユーザーに示されます。
注意
SearchBar
名前空間の Xamarin.Forms.PlatformConfiguration.WindowsSpecific
クラスにはEnableSpellCheck
、 のDisableSpellCheck
スペル チェックSearchBar
を有効または無効にするために使用できる メソッドと メソッドも用意されています。