HOW TO:在文字編輯控制項中啟用拼字檢查
更新:2007 年 11 月
下列範例說明如何使用 SpellCheck 類別的 IsEnabled 屬性,在 TextBox 中啟用即時拼字檢查。
範例
<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<TextBox SpellCheck.IsEnabled="True" Name="myTextBox"></TextBox>
</StackPanel>
</Page>
using System;
using System.Windows;
using System.Windows.Controls;
namespace SDKSample
{
public partial class SpellCheckExample : Page
{
public SpellCheckExample()
{
StackPanel myStackPanel = new StackPanel();
//Create TextBox
TextBox myTextBox = new TextBox();
myTextBox.Width = 200;
// Enable spellchecking on the TextBox.
myTextBox.SpellCheck.IsEnabled = true;
// Alternatively, the SetIsEnabled method could be used
// to enable or disable spell checking like this:
// SpellCheck.SetIsEnabled(myTextBox, true);
myStackPanel.Children.Add(myTextBox);
this.Content = myStackPanel;
}
}
}