I'm using Telerik 2011.3.1116.35 and VS2008 with a RadRichtextBox. Actually I use a RtdDataProvider to add Rtf document in my RadRichTextBox.
When I try to insert new text at the end of my RadRichTextBox, the new text seems to clear the current content of my RadRichTextBox bedfore insert my new text.
Here is the xaml:
<Window x:Class="WpfApplication3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:telerikProvider="clr-namespace:Telerik.Windows.Documents.FormatProviders.Rtf;assembly=Telerik.Windows.Documents.FormatProviders.Rtf"
Title="Window1" Height="300" Width="641">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=editor, Path=Commands}">
<telerik:RadRibbonToggleButton Text="B" FontFamily="Times New Roman" FontSize="14" FontWeight="Bold" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBoldCommand}" />
<telerik:RadRibbonToggleButton Text="I" FontFamily="Times New Roman" FontSize="14" FontStyle="Italic" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleItalicCommand}" />
<telerik:RadRibbonToggleButton FontFamily="Times New Roman" FontSize="14" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleUnderlineCommand}">
<Underline>U</Underline>
</telerik:RadRibbonToggleButton>
<telerik:RadButton Click="RadButton_Click">Test</telerik:RadButton>
</StackPanel>
<telerik:RadRichTextBox Grid.Row="1" x:Name="editor" Margin="24 24 0 0" AllowDrop="True" ShowComments="True" IsSelectionMiniToolBarEnabled="False" IsContextMenuEnabled="False" />
<telerikProvider:RtfDataProvider Name="Rtf" RichTextBox="{Binding ElementName=editor}" />
<telerik:DocumentRuler AssociatedRichTextBox="{Binding ElementName=editor, Mode=OneTime}" Grid.Row="1" />
<telerik:RadRichTextBoxStatusBar Grid.Row="2" AssociatedRichTextBox="{Binding ElementName=editor, Mode=OneTime}" />
</Grid>
</Window>
Here is the code-behind:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
using
VPlayer;
using
Telerik.Windows.Documents.Model.Styles;
namespace
WpfApplication3
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void RadButton_Click(object sender, RoutedEventArgs e)
{
Rtf.Rtf =
"Line 1";
editor.Document.CaretPosition.MoveToLastPositionInDocument();
editor.Insert(
@"Line 2");
}
}
}
Thank's