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.SetIsSpellCheckEnabledXamarin.Forms.PlatformConfiguration.WindowsSpecific、スペル チェックのオンとオフを切り替えます。 さらに、 メソッドを SearchBar.SetIsSpellCheckEnabled 使用してスペル チェックを切り替えるには、 メソッドを SearchBar.GetIsSpellCheckEnabled 呼び出して、スペル チェックが有効になっているかどうかを返します。

searchBar.On<Windows>().SetIsSpellCheckEnabled(!searchBar.On<Windows>().GetIsSpellCheckEnabled());

その結果、 に SearchBar 入力されたテキストはスペル チェックが可能になり、誤ったスペルがユーザーに示されます。

SearchBar スペル チェックプラットフォーム固有

注意

SearchBar名前空間の Xamarin.Forms.PlatformConfiguration.WindowsSpecific クラスにはEnableSpellCheck、 のDisableSpellCheckスペル チェックSearchBarを有効または無効にするために使用できる メソッドと メソッドも用意されています。