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 :
Here is the control that is used for our table :
Here is the GridView table we use :
And last but not least, this how we get our DataTemplate for each column :
Thanks in advance !
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"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
BorderBrush
=
"Transparent"
Background
=
"Transparent"
x:Name
=
"thisUserControl"
d:DesignHeight
=
"300"
d:DesignWidth
=
"300"
>
<
Grid
>
<
telerik:HtmlDataProvider
x:Name
=
"htmlDataProvider"
RichTextBox
=
"{Binding ElementName=richTextBox}"
Html
=
"{Binding Path=HtmlValue, ElementName=thisUserControl, Mode=TwoWay}"
>
<
telerik:HtmlDataProvider.FormatProvider
>
<
telerik:HtmlFormatProvider
>
<
telerik:HtmlFormatProvider.ExportSettings
>
<
telerik:HtmlExportSettings
DocumentExportLevel
=
"Fragment"
ExportStyleMetadata
=
"False"
StyleRepositoryExportMode
=
"DontExportStyles"
StylesExportMode
=
"Inline"
ExportFontStylesAsTags
=
"True"
/>
</
telerik:HtmlFormatProvider.ExportSettings
>
</
telerik:HtmlFormatProvider
>
</
telerik:HtmlDataProvider.FormatProvider
>
</
telerik:HtmlDataProvider
>
<
telerik:RadRichTextBox
x:Name
=
"richTextBox"
DocumentInheritsDefaultStyleSettings
=
"True"
BorderBrush
=
"Transparent"
Background
=
"Transparent"
AcceptsTab
=
"False"
/>
</
Grid
>
</
UserControl
>
Here is the control that is used for our table :
<
UserControl.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"DataTemplates.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
UserControl.Resources
>
<
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"
SelectedValuePath
=
"Value"
telerik:StyleManager.Theme
=
"Metro"
ItemsSource
=
"{Binding StatusItems, Converter={StaticResource EnumToListConverter}}"
SelectedValue
=
"{Binding Path=Entry.Status}"
>
<
telerik:RadComboBox.ItemTemplate
>
<
DataTemplate
>
<
Label
Content
=
"{Binding Path=Text}"
Foreground
=
"{Binding Path=Color}"
></
Label
>
</
DataTemplate
>
</
telerik:RadComboBox.ItemTemplate
>
</
telerik:RadComboBox
>
</
ContentControl
>
<
Common:RichTextEditor
HtmlValue
=
"{Binding Path=Entry.Text, Mode=TwoWay}"
GotFocus
=
"richTextBox_GotFocus"
LostFocus
=
"richTextBox_LostFocus"
></
Common:RichTextEditor
>
<
my:ReferencesEditor
x:Name
=
"referencesEditor"
References
=
"{Binding Path=Entry, Converter={StaticResource ResourceKey=ReferenceContainerConverter}}"
/>
</
StackPanel
>
Here is the GridView table we use :
<
ScrollViewer
HorizontalScrollBarVisibility
=
"Auto"
VerticalScrollBarVisibility
=
"Auto"
>
<
StackPanel
Orientation
=
"Vertical"
>
<
telerik:RadGridView
x:Name
=
"gridView"
RowIndicatorVisibility
=
"Collapsed"
SelectedItem
=
"{Binding SelectedItem}"
CanUserReorderColumns
=
"False"
GridLinesVisibility
=
"Horizontal"
ShowGroupPanel
=
"False"
BorderThickness
=
"0"
AutoGenerateColumns
=
"False"
CanUserSortColumns
=
"False"
CanUserFreezeColumns
=
"False"
ColumnWidth
=
"*"
BeginningEdit
=
"GridView_OnBeginningEdit"
ItemsSource
=
"{Binding Path=Finding.Items.List}"
EnableRowVirtualization
=
"False"
EnableColumnVirtualization
=
"False"
telerik:StyleManager.Theme
=
"Windows7"
>
<
telerik:RadGridView.SortDescriptors
>
<
telerik:SortDescriptor
Member
=
"SortOrder"
SortDirection
=
"Ascending"
/>
</
telerik:RadGridView.SortDescriptors
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
IsReadOnly
=
"True"
DataMemberBinding
=
"{Binding Path=Code}"
CellStyle
=
"{StaticResource ResourceKey=CustomCellStyle}"
Header
=
"Type"
Width
=
"Auto"
/>
<!-- More columns are added here dynamically by the code behind this file -->
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
<
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}}"
Margin
=
"0,0,0,5"
/>
</
StackPanel
>
</
ScrollViewer
>
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 !