I would like to disable the spell checker in a Windows Phone 8.1 application, which is on by default on an AutoSuggestBox, but not desired:
The markup of the control:
<AutoSuggestBox
Name="txtOrgunit"
TextChanged="txtOrgunit_TextChanged"
SuggestionChosen="txtOrgunit_SuggestionChosen">
</AutoSuggestBox>
How can I achieve that the IsSpellCheckEnabled
property goes false on the internal textbox from markup or from code?
Existing solutions I have found either deal with the same problem on other platforms (like this:
How can I disable the spell checker on text inputs on the iPhone
and this:
how to disable spell checker for Android AutoCompleteTextView?)
or they are unwieldy rocket science, like this:
EDIT: After applying the solution proposed in the first answer verbatim, the OP goal is achieved, but the functionality of the control is broken (the event is raised, the itemssource ends up with 30 items, but none of them is shown - no "dropdown" appears any more). Therefore I give the source code of the txtOrgunit_TextChanged
handler below:
private void txtOrgunit_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
{
var ui = sender.Text.Trim().ToUpperInvariant();
var matches = new List<IdAndCaption>();
var count = 0;
for (int i = 0; i < Com.MasterdataBasic.Orgunits.Length; ++i)
{
var cand = Com.MasterdataBasic.Orgunits[i];
var cap = String.Format("{0} {1}", cand.Abbrev, cand.LongCap);
if (cap.ToUpperInvariant().Contains(ui))
{
var ele = new IdAndCaption() { Id = cand.OrgID, Caption = cap };
matches.Add(ele);
++count;
/* UX decided it unreasonable to have the user scroll through more...
* should type more letters to restrict further */
if (count >= 30) break;
}
}
sender.ItemsSource = matches;
Rec.Report.OrgID = -1;
}
}
I verified that when I remove the style tag from the autosuggestbox, the autosuggest functionality is restored.