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

Bold, Italic, Underline

3 Answers 297 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 29 Nov 2011, 08:14 PM

Hi,

I would like to know if it's possible to have a RadRichText with a toolbar that containing only 3 buttons, bold, italic and underline. All of these buttons shoud have an impact direct on the text.

I need something like:

 

<

 

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"

 

 

 

 

 

 

Title="Window1" Height="300" Width="641">

 

 

 

 

 

 

 

<Grid>

 

 

 

 

 

 

 

<Grid.RowDefinitions>

 

 

 

 

 

 

 

<RowDefinition Height="Auto"/>

 

 

 

 

 

 

 

<RowDefinition Height="*"/>

 

 

 

 

 

 

 

<RowDefinition Height="Auto"/>

 

 

 

 

 

 

 

</Grid.RowDefinitions>

 

 

 

 

 

 

 

 

<StackPanel Orientation="Horizontal">

 

 

 

 

 

 

 

<telerik:RadRibbonToggleButton Text="Bold" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBoldCommand}" />

 

 

 

 

 

 

 

<telerik:RadRibbonToggleButton Text="Italic" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleItalicCommand}" />

 

 

 

 

 

 

 

<telerik:RadRibbonToggleButton Text="Underline" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleUnderlineCommand}" />

 

 

 

</StackPanel>

 

 

 

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

 

 

 

 

 

 

 

<telerik:DocumentRuler AssociatedRichTextBox="{Binding ElementName=editor, Mode=OneTime}" Grid.Row="1" />

 

 

 

 

 

 

 

<telerik:RadRichTextBoxStatusBar Grid.Row="2" AssociatedRichTextBox="{Binding ElementName=editor, Mode=OneTime}" />

 

 

 

 

 

 

 

</Grid>

 

</

 

Window>

 

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 02 Dec 2011, 01:22 PM
Hello Oliver,

The only thing you need to add is to set the DataContext of the StackPanel to the Commands property of the rich text box. This can be done like this:

<StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=editor, Path=Commands}">

In that way, the buttons will be wired to use the the respective commands of the editor they are bound to.

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Oliver
Top achievements
Rank 1
answered on 02 Dec 2011, 07:53 PM
Hi,

now, I have a reference to RibbonBar and RibbonView and when I try to build my application I have to folowwing message:

The type 'Telerik.Windows.Controls.RadRibbonButton' exists in both 'd:\Developpement\GestX.Courant\RisGC\SDK\Telerik\Telerik.Windows.Controls.RibbonBar.dll' and 'd:\Developpement\GestX.Courant\RisGC\SDK\Telerik\Telerik.Windows.Controls.RibbonView.dll' D:\Developpement\GestX.Courant\RisGC\Client\DictationModuleWPF\DictationForm.xaml 59 43 DictationModuleWPF

Here is some part of my XAML:

<

 

telerik:RadWindow x:Class="com.christiegrp.Neuron.ClientApplication.DictationForm"

 

 

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:helper="clr-namespace:com.christiegrp.Neuron.ClientApplication;assembly=ClientHelper"

 

 

xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls.Navigation;assembly=Telerik.Windows.Controls.Navigation"

 

 

xmlns:telerikProvider="clr-namespace:Telerik.Windows.Documents.FormatProviders.Rtf;assembly=Telerik.Windows.Documents.FormatProviders.Rtf"

 

 

Header="DictationForm" Name="Me" WindowState="Maximized" SizeToContent="False" PreviewClosed="Me_PreviewClosed"

 

 

telerik:PersistenceManager.StorageId="DictationForm" telerikNavigation:RadWindowInteropHelper.AllowTransparency="false">



 

 

 

<telerik:RadRibbonBar.ApplicationMenu>

 

 

 

<telerik:ApplicationMenu telerik:KeyTipService.AccessText="F">

 

 

 

<telerik:ApplicationMenu.FooterContent>

 

 

 

 

 

 

<StackPanel Height="25" Orientation="Horizontal">

 

 

 

 

 

 

<telerik:RadButton Width="106" Height="22" Margin="3 0" Click="mnuBtnQuit_Click">

 

 

 

 

 

 

<telerik:RadButton.Content>

 

 

 

 

 

 

<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="3 0 5 0">

 

 

 

 

 

 

<Image Width="16" Height="16" Source="Resources/Exit_32x32.png" />

 

 

 

 

 

 

<TextBlock Margin="4 0 0 0" VerticalAlignment="Center" Text="{StaticResource Quit}" />

 

 

 

 

 

 

</StackPanel>

 

 

 

 

 

 

</telerik:RadButton.Content>

 

 

 

 

 

 

</telerik:RadButton>

 

 

 

 

 

 

</StackPanel>

 

 

 

 

 

 

</telerik:ApplicationMenu.FooterContent>

 

 

 

 

 

 

 

<telerik:RadRibbonButton Name="mnuBtnPersist" Text="{StaticResource PersistLayout}" LargeImage="Resources/Persist_32x32.png" Click="mnuBtnPersist_Click" />

 

 

 

 

 

 

<telerik:Separator />

 

 

 

 

 

 

<telerik:RadRibbonButton Name="mnuBtnLockDocking" Text="{StaticResource LockDocking}" LargeImage="Resources/LockDocking_32x32.png" Click="mnuBtnLockDocking_Click" />

 

 

 

 

 

 

<telerik:RadRibbonButton Name="mnuBtnUnlockDocking" Text="{StaticResource UnlockDocking}" LargeImage="Resources/UnlockDocking_32x32.png" Click="mnuBtnUnlockDocking_Click" />

 

 

 

 

 

 

<telerik:Separator />

 

 

 

 

 

 

<telerik:RadRibbonButton Name="mnuBtnResetDocking" Text="{StaticResource ResetDocking}" LargeImage="Resources/ResetDocking_32x32.png" Click="mnuBtnResetDocking_Click" />

 

 

 

 

 

 

<telerik:RadRibbonButton Name="mnuBtnResetUserDocking" Text="{StaticResource ResetUserDocking}" LargeImage="Resources/ResetUserDocking_32x32.png" Click="mnuBtnResetUserDocking_Click" />

 

 

 

 

 

 

<telerik:Separator />

 

 

 

 

 

 

<telerik:RadRibbonButton Name="mnuBtnQuit" Text="{StaticResource Quit}" LargeImage="Resources/Exit_32x32.png" Click="mnuBtnQuit_Click"/>

 

 

 

 

 

 

</telerik:ApplicationMenu>

 

 

 

 

 

 

</telerik:RadRibbonBar.ApplicationMenu>

 



 

 

<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal" DataContext="{Binding ElementName=radRichTextCurrentReport, 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>

 

 

</StackPanel>

Environment:

VS2008
DotNet: 3.5
Teelrik: 2011.3.1116.35

Thank's

 

0
Iva Toteva
Telerik team
answered on 02 Dec 2011, 08:26 PM
Hello Oliver,

Telerik.Windows.Controls.RibbonView contains the new implementation of a ribbon control - RadRibbonView, while Telerik.Windows.Controls.RibbonBar contains the old implementation - RadRibbonBar. The two controls cannot be used in the same project, so you need to remove the reference to the assembly you are not using. The advantages of using the new control compared to the
old one are described in detail in this blog post.

RadRichTextBox has a predefined UI based on the ribbon controls which you can use out of the box - RadRichTextBoxRibbonUI. In the versions before 2011.Q3.Beta (2011.3.1020), RadRichTextBoxRibbonUI was based on RadRibbonBar, but starting from the version in question (and including 2011.3.1116), it uses the new RadRibbonView instead. You can also refer to this article for more information on the assembly references and versions. You can also check the TelerikEditor demo from our ClickOnce demos or run the examples locally, if you have downloaded/installed them along with the controls.

Regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Oliver
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or