This is a migrated thread and some comments may be shown as answers.

is it possible to assign string value to rad richtextbox and vice a versa

7 Answers 392 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Parthiv
Top achievements
Rank 1
Parthiv asked on 28 Aug 2010, 12:51 PM
Hi,

My requirement is i need to allow user to enter remarks and description using different style it should be same as FCKEditor but
now i m very much fed up with silverlight telerik control i started with Editor and then came to know that editor is replaced by
RichTextBox now here i m not able to get simple senario where i can simply bind or assign my string to radrichtextbox and how i can retrive its value actully i hav used radribbon i dont want save button and all those stuff i only need font tab so i used only that much
but now i dont know wht to do next i m not getting single help or document which will taught me that how to assign value instead of document or xml ?

Below is my xaml code

 

 

   <telerik:RadRichTextBoxRibbonUI ApplicationName="Enter your Description" ApplicationButtonImageSource="/RichTextBox;component/Images/RichTextBox/MSOffice/AppIcon-telerik.png" Name="radRichTextBoxRibbonUI1" DataContext="{Binding ElementName=editor}">

            <telerik:RadRibbonTab Header="Home">
                <telerik:RadRibbonGroup Header="Clipboard">
                    <telerik:RadRibbonGroup.Variants>
                        <telerik:GroupVariant Priority="0" Variant="Medium" />
                    </telerik:RadRibbonGroup.Variants>
                    <StackPanel>
                        <telerik:RadRibbonButton CollapseToSmall="WhenGroupIsMedium" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=CutCommand}" Size="Medium" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/cut.png" Text="Cut" />
                        <telerik:RadRibbonButton CollapseToSmall="WhenGroupIsMedium" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=CopyCommand}" Size="Medium" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/copy.png" Text="Copy" />
                        <telerik:RadRibbonButton CollapseToSmall="WhenGroupIsMedium" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=PasteCommand}" Size="Medium" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/paste.png" Text="Paste" />
                    </StackPanel>
                </telerik:RadRibbonGroup>
                <telerik:RadRibbonGroup Header="Font">
                    <telerik:RadRibbonGroup.Variants>
                        <telerik:GroupVariant Priority="2" Variant="Medium" />
                        <telerik:GroupVariant Priority="4" Variant="Small" />
                        <telerik:GroupVariant Priority="5" Variant="Collapsed" />
                    </telerik:RadRibbonGroup.Variants>
                    <telerik:RadOrderedWrapPanel>
                        <StackPanel Orientation="Horizontal">
                            <telerik:RadRibbonComboBox CanAutocompleteSelectItems="False" CanKeyboardNavigationSelectItems="False" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}" Height="21" IsEditable="False" IsReadOnly="True" OpenDropDownOnFocus="True" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontFamilyCommand}" Width="110">
                                <telerik:RadRibbonComboBoxItem Content="Arial" FontFamily="Arial" Tag="Arial" />
                                <telerik:RadRibbonComboBoxItem Content="Arial Black" FontFamily="Arial Black" Tag="Arial Black" />
                                <telerik:RadRibbonComboBoxItem Content="Calibri" FontFamily="Calibri" Tag="Calibri" />
                                <telerik:RadRibbonComboBoxItem Content="Comic Sans MS" FontFamily="Comic Sans MS" Tag="Comic Sans MS" />
                                <telerik:RadRibbonComboBoxItem Content="Courier New" FontFamily="Courier New" Tag="Courier New" />
                                <telerik:RadRibbonComboBoxItem Content="Georgia" FontFamily="Georgia" Tag="Georgia" />
                                <telerik:RadRibbonComboBoxItem Content="Lucida Sans Unicode" FontFamily="Lucida Sans Unicode" Tag="Lucida Sans Unicode" />
                                <telerik:RadRibbonComboBoxItem Content="Times New Roman" FontFamily="Times New Roman" Tag="Times New Roman" />
                                <telerik:RadRibbonComboBoxItem Content="Trebuchet MS" FontFamily="Trebuchet MS" Tag="Trebuchet MS" />
                                <telerik:RadRibbonComboBoxItem Content="Verdana" FontFamily="Verdana" Tag="Verdana" />
                            </telerik:RadRibbonComboBox>
                            <telerik:RadRibbonComboBox CanAutocompleteSelectItems="False" CanKeyboardNavigationSelectItems="False" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Tag}" Height="21" IsEditable="False" IsReadOnly="True" OpenDropDownOnFocus="True" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontSizeCommand}" Width="45">
                                <telerik:RadRibbonComboBoxItem Content="8" Tag="10.67" />
                                <telerik:RadRibbonComboBoxItem Content="9" Tag="12" />
                                <telerik:RadRibbonComboBoxItem Content="10" Tag="13.33" />
                                <telerik:RadRibbonComboBoxItem Content="11" Tag="14.67" />
                                <telerik:RadRibbonComboBoxItem Content="12" Tag="16" />
                                <telerik:RadRibbonComboBoxItem Content="14" Tag="18.67" />
                                <telerik:RadRibbonComboBoxItem Content="16" Tag="21.33" />
                                <telerik:RadRibbonComboBoxItem Content="18" Tag="24" />
                                <telerik:RadRibbonComboBoxItem Content="20" Tag="26.67" />
                                <telerik:RadRibbonComboBoxItem Content="22" Tag="29.33" />
                                <telerik:RadRibbonComboBoxItem Content="24" Tag="32" />
                                <telerik:RadRibbonComboBoxItem Content="26" Tag="34.67" />
                                <telerik:RadRibbonComboBoxItem Content="28" Tag="37.33" />
                                <telerik:RadRibbonComboBoxItem Content="36" Tag="48" />
                                <telerik:RadRibbonComboBoxItem Content="48" Tag="64" />
                                <telerik:RadRibbonComboBoxItem Content="72" Tag="96" />
                            </telerik:RadRibbonComboBox>
                        </StackPanel>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=IncrementFontSizeCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/font-increasesize.png" />
                            <telerik:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=DecrementFontSizeCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/font-decreasesize.png" />
                        </telerik:RadButtonGroup>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ClearFormattingCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/ClearFormatting16.png" />
                        </telerik:RadButtonGroup>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBoldCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/bold.png" />
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleItalicCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/italic.png" />
                            <telerik:RadRibbonSplitButton IsToggle="True" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleUnderlineCommand}" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/underline.png">
                                <telerik:RadRibbonSplitButton.DropDownContent>
                                    <telerik:RadGallery ItemHeight="26" ItemWidth="156" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeUnderlineDecorationCommand}" ViewportHeight="210" ViewportWidth="157">
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline1.png" Tag="Line" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline2.png" Tag="DoubleLine" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline3.png" Tag="ThickLine" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline4.png" Tag="DottedLine" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline5.png" Tag="DashedLine" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline6.png" Tag="DotDashedLine" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline7.png" Tag="DotDotDashedLine" />
                                        <telerik:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline8.png" Tag="Wave" />
                                    </telerik:RadGallery>
                                </telerik:RadRibbonSplitButton.DropDownContent>
                            </telerik:RadRibbonSplitButton>
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleStrikethroughCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/Strikethrough16.png" />
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleSubscriptCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/subscript.png" />
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleSuperscriptCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/superscript.png" />
                        </telerik:RadButtonGroup>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonSplitButton CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=DropDownContent.SelectedColor}" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontHighlightColorCommand}">
                                <telerik:RadRibbonSplitButton.DropDownContent>
                                    <telerik:RadColorSelector Name="highlightColorSelector" NoColorVisibility="Collapsed" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontHighlightColorCommand}" SelectedColor="Yellow" />
                                </telerik:RadRibbonSplitButton.DropDownContent>
                                <Grid>
                                    <Image Source="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/highlight.png" Stretch="None" />
                                    <Rectangle Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
                                        <Rectangle.Fill>
                                            <SolidColorBrush Color="{Binding Path=SelectedColor, ElementName=highlightColorSelector}" />
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Grid>
                            </telerik:RadRibbonSplitButton>
                            <telerik:RadRibbonSplitButton CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=DropDownContent.SelectedColor}" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontForeColorCommand}">
                                <telerik:RadRibbonSplitButton.DropDownContent>
                                    <telerik:RadColorSelector Name="foreColorSelector" NoColorVisibility="Collapsed" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontForeColorCommand}" SelectedColor="Red" />
                                </telerik:RadRibbonSplitButton.DropDownContent>
                                <Grid>
                                    <Image Source="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/fontcolor.png" Stretch="None" />
                                    <Rectangle Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
                                        <Rectangle.Fill>
                                            <SolidColorBrush Color="{Binding Path=SelectedColor, ElementName=foreColorSelector}" />
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Grid>
                            </telerik:RadRibbonSplitButton>
                        </telerik:RadButtonGroup>
                    </telerik:RadOrderedWrapPanel>
                </telerik:RadRibbonGroup>
                <telerik:RadRibbonGroup DialogLauncherVisibility="Visible" Header="Paragraph" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ShowParagraphPropertiesDialogCommand}">
                    <telerik:RadRibbonGroup.Variants>
                        <telerik:GroupVariant Priority="1" Variant="Medium" />
                        <telerik:GroupVariant Priority="3" Variant="Collapsed" />
                    </telerik:RadRibbonGroup.Variants>
                    <telerik:RadOrderedWrapPanel>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBulletsCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/list-bullets.png" />
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleNumberedCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/list-numbered.png" />
                        </telerik:RadButtonGroup>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=DecrementParagraphLeftIndentCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/outdent.png" />
                            <telerik:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=IncrementParagraphLeftIndentCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/indent.png" />
                        </telerik:RadButtonGroup>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleFormattingSymbolsCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/formatting-symbols.png" />
                        </telerik:RadButtonGroup>
                        <telerik:RadButtonGroup>
                            <telerik:RadRibbonToggleButton CommandParameter="Left" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/alignleft.png" Text="Align Left" />
                            <telerik:RadRibbonToggleButton CommandParameter="Center" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/aligncenter.png" Text="Center" />
                            <telerik:RadRibbonToggleButton CommandParameter="Right" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/alignright.png" Text="Align Right" />
                            <telerik:RadRibbonToggleButton CommandParameter="Justify" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/alignjustify.png" Text="Justify" />
                        </telerik:RadButtonGroup>
                    </telerik:RadOrderedWrapPanel>
                </telerik:RadRibbonGroup>
            </telerik:RadRibbonTab>
            <telerik:RadRibbonTab Header="Insert">

                <telerik:RadRibbonGroup Header="Links">
                    <telerik:RadRibbonButton LargeImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/32/inserthyperlink.png" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ShowInsertHyperlinkDialogCommand}" Size="Large" Text="Hyperlink" />
                </telerik:RadRibbonGroup>
                <telerik:RadRibbonGroup Header="Symbol">
                    <telerik:RadRibbonButton LargeImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/32/Symbol.png" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ShowInsertSymbolWindowCommand}" Size="Large" Text="Symbol" />
                </telerik:RadRibbonGroup>
            </telerik:RadRibbonTab>

        </telerik:RadRichTextBoxRibbonUI>

        <telerik:RadRichTextBox  Grid.Row="1"  x:Name="editor"
                                      Margin="24 24 0 0" AllowDrop="True" 
                                     >
        </telerik:RadRichTextBox>



is it possible to assign string value to rad richtextbox and vice a versa ?

Pls help me  and if not then pls suggest me wht other control in silverlgiht so that i can use that ?

7 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 30 Aug 2010, 12:52 PM
Hello Parthiv,

Importing and exporting plain text (a simple string) to and from RadRichTextBox can be achieved in the same manner as the more complicated HTML, XAML, etc. formats. The most straightforward way to do this would be
radRichTextBox.Document = new TxtFormatProvider().Import(myString);
where myString would be a variable of type string which would be imported as plain text.
More generally, importing from plain text is done through the TxtFormatProvider or, declaratively, through the TxtDataProvider. I have posted above the best way to utilize the first, and you can find more details on the second here (using the TxtDataProvider will allow you to avoid any code-behind and implement the entire functionality in XAML). While the data provider is most useful when used together with Silverlight's bindings, a simple string can be assigned to the Text property if that is what you want.
Which one of those two approaches will be more appropriate for you depends on your specific use case.

Best wishes,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ss
Top achievements
Rank 1
answered on 15 Sep 2010, 01:47 PM

Iread following articIe:

http://www.telerik.com/help/silverlight/radrichtextbox-how-to-binding-to-data-providers.html

I dont know why but I am not able to use HtmlDataProvider because there is no HtmlDataProvider class in Telerik.Windows.Documents.FormatProviders.Html. There is only HtmlFormatProvider but HtmlFormatProvider doesnt have RitchTextBox property. 

Can you please help me how to resolve this problem? 

Thank you.

0
Ivailo Karamanolev
Telerik team
answered on 15 Sep 2010, 03:00 PM
Hi ss,

The only reason for you to be unable to find HtmlDataProvider might be if you're using an older version of Telerik.Windows.Documents.FormatProviders.Html.dll. Please check, and I'd recommend replace, your assembly and make sure it's Q2 SP1. Additionally, you can also try the LIB and see if it makes any difference.
Also, please note that the namespace Telerik.Windows.Documents.FormatProviders.Html exists in two assemblies - Telerik.Windows.Documents.dll and the above mentioned Telerik.Windows.Documents.FormatProviders.Html.dll. The class you're searching for is inside the latter.
Don't hesitate to contact us if your problems persist.

Best wishes,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ss
Top achievements
Rank 1
answered on 16 Sep 2010, 10:00 AM

0
Ivailo Karamanolev
Telerik team
answered on 17 Sep 2010, 08:26 AM
Hello ss,

Your message appears to be empty. If you have any issue, please check that you have submitted it correctly.

Regards,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adrian
Top achievements
Rank 2
answered on 27 Dec 2012, 12:05 AM
No matter what I do I can not find the namespace Telerik.Windows.Documents and hence can not declare radDocuments nor the text provider. I have winforms 2012 Q3 and don't see any .dlls with windows in it. The only .dlls are the .WinControls ones.
0
Boryana
Telerik team
answered on 27 Dec 2012, 01:42 PM
Hi Marvin,

Thank you for writing.

Please note that the current forum thread concerns RichTextBox for Silverlight. I kindly ask you to post questions regarding RichTextBox for WinForms in the appropriate forum: http://www.telerik.com/community/forums/winforms/richtextbox.aspx.

Thank you for your cooperation.

All the best,
Boryana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Parthiv
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
ss
Top achievements
Rank 1
Adrian
Top achievements
Rank 2
Boryana
Telerik team
Share this question
or