Spellchecking problem

3 posts, 1 answers
  1. ASSYST2 - CGI
    ASSYST2 - CGI avatar
    12 posts
    Member since:
    Nov 2013

    Posted 04 Nov 2013 Link to this post

    Hello everyone,

    We are encountering a little issue with spellchecking function of the richtextbox.

    Let me explain the context : we are using Framework 3.5 and the runtime version of the Telerik library is v2.0.50727 for WPF.
    Why 3.5? Because we also use Sharepoint 2010 and we have an application working with MVVM design pattern.

    So here is our problem : we have a wpf page that creates dynamicly a table (rows and columns are dynamics) with a RichtextBox and each cell. Each cell has the right text and works fine. But whenever we try to use the spellcheck, it doesn't work. We investigated and realised that even if the spellcheck would see the wrong words on the control, you can't change it from the Right click context menu. We then realised that when we open up the context spell checking window, it automatically select the content of the first richtextbox object we have on the page. So even if the text content is the right one, it tries to replace it from the first RichtextBox of the table. Same goes for the Copy and paste functions.

    First, we are not using the Telerik rich textbox by itself, we have another control that herits from it :
    <UserControl x:Class="Eca.Assyst.Client.Common.RichTextEditor"
            <telerik:HtmlDataProvider x:Name="htmlDataProvider"
                                      RichTextBox="{Binding ElementName=richTextBox}" 
                                      Html="{Binding Path=HtmlValue, ElementName=thisUserControl, Mode=TwoWay}">
                            <telerik:HtmlExportSettings DocumentExportLevel="Fragment" 
                                                        ExportFontStylesAsTags="True" />
            <telerik:RadRichTextBox x:Name="richTextBox" 
                                    AcceptsTab="False" />

    Here is the control that is used for our table :
                    <ResourceDictionary Source="DataTemplates.xaml" />
        <StackPanel Margin="0,2,0,0"
                    d:DataContext="{StaticResource ResourceKey=FindingEntryEditorViewModelMock}">
            <ContentControl x:Name="DropDownContainer"
                            Visibility="{Binding Path=DisplayStatusDropDown, Converter={StaticResource BooleanToVisibilityConverter}}">
                <telerik:RadComboBox x:Name="StatusComboBox"
                                    ItemsSource="{Binding StatusItems, Converter={StaticResource EnumToListConverter}}" 
                                    SelectedValue="{Binding Path=Entry.Status}">
                            <Label Content="{Binding Path=Text}" Foreground="{Binding Path=Color}"></Label>
            <Common:RichTextEditor HtmlValue="{Binding Path=Entry.Text, Mode=TwoWay}"
            <my:ReferencesEditor x:Name="referencesEditor" References="{Binding Path=Entry, Converter={StaticResource ResourceKey=ReferenceContainerConverter}}" />

    Here is the GridView table we use :
    <ScrollViewer HorizontalScrollBarVisibility="Auto"
                                <StackPanel Orientation="Vertical">
                                    <telerik:RadGridView x:Name="gridView"
                                                         SelectedItem="{Binding SelectedItem}"
                                                         ItemsSource="{Binding Path=Finding.Items.List}"
                                            <telerik:SortDescriptor Member="SortOrder" SortDirection="Ascending"/>
                                            <telerik:GridViewDataColumn IsReadOnly="True"
                                                                        DataMemberBinding="{Binding Path=Code}"
                                                                        CellStyle="{StaticResource ResourceKey=CustomCellStyle}"
                                                                        Width="Auto" />
                                            <!-- More columns are added here dynamically by the code behind this file -->
                                    <AuditProgrammeEditor:FindingErrorSpecificationControl x:Name="ErrorSpecification"
                                                                                           Visibility="{Binding Path=DataContext.ShowAmountsTable, ElementName=MainContainer, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}"
                                                                                           DataContext="{Binding MasterErrorEntry}"
                                                                                           IsEnabled="{Binding Path=DataContext.ReadOnly, ElementName=gridView, Converter={StaticResource ResourceKey=BooleanToInvertedBooleanConverter}}"

    And last but not least, this how we get our DataTemplate for each column :
    public DataTemplate GetTemplate(int columnIndex, bool isEnabled)
                var templateXaml = Properties.Resources.FindingTableEntryTemplate;
                templateXaml = templateXaml.Replace("{EntryIndex}", columnIndex.ToString(CultureInfo.InvariantCulture));
                templateXaml = templateXaml.Replace("{IsEnabled}", isEnabled.ToString(CultureInfo.InvariantCulture));
                var stream = new MemoryStream(Encoding.Default.GetBytes(templateXaml));
                return (DataTemplate)XamlReader.Load(stream);

    Thanks in advance !
  2. Answer
    Boby avatar
    763 posts

    Posted 07 Nov 2013 Link to this post

    Hello Fabien,
    The behavior is known peculiarity related to the fact that by default ContextMenu has one instance shared between all instances of RadRichTextBox. You can work around the issue by creating custom context menu which is non-sharable. It will be downloaded automatically by MEF so you don't need to register it in any way rather that declaring it. The approach is described in this forum answer (the second approach).

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. ASSYST2 - CGI
    ASSYST2 - CGI avatar
    12 posts
    Member since:
    Nov 2013

    Posted 07 Nov 2013 Link to this post

    Thank I'll try to implement that. I'll let you know when I get there!
Back to Top