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