WPF – Spell checking

I investigates last week to add spellchecking on the localize view of CBR to help us in translation…A quick search on internet tells me that, with net 4, I need the language packs (fr+en+de). Note that it’s not the same with NET3.5.

To download them : http://www.microsoft.com/en-us/download/details.aspx?id=3324

Then I had to bind my text boxes to the current language I already had in my view model as string…

<TextBox Text=”{Binding Path=Translated}” HorizontalAlignment=”Stretch” SpellCheck.IsEnabled=”True” Language=”{Binding DataContext.ActualCode, RelativeSource={RelativeSource AncestorType=ListView}}”

PAF ! Exception !

Binding for property ‘Language’ cannot use the target element’s Language for conversion; if a culture is required, ConverterCulture must be explicitly specified on the Binding.

A second and more longer search brings me to the fact that “Language” property in xaml require a special converter that need also a special “parameter”

The solution is : Add the namespace

xmlns:glob=”clr-namespace:System.Globalization;assembly=mscorlib”

Language=”{Binding DataContext.ActualCode, RelativeSource={RelativeSource AncestorType=ListView}, ConverterCulture={x:Static glob:CultureInfo.InvariantCulture}}”

Advertisements

One thought on “WPF – Spell checking

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s