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

ApplicationCommands Cut/Copy

1 Answer 235 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
luc
Top achievements
Rank 1
luc asked on 26 Aug 2011, 10:36 AM
Hi,

I have a very small program with a radmenu and radrichtextbox to demonstrate the use of applicationCommands.

 

 

 <Grid>

 <Grid.RowDefinitions>

 <RowDefinition Height="Auto" />

 <RowDefinition />

 </Grid.RowDefinitions>

 <telerik:RadMenu>

 <telerik:RadMenuItem Header="Edit">

 <telerik:RadMenuItem Header="Cut" Command="ApplicationCommands.Cut"/>

 <telerik:RadMenuItem Header="Paste" Command="ApplicationCommands.Paste"/>

 </telerik:RadMenuItem>

 </telerik:RadMenu>

 <telerik:RadRichTextBox Grid.Row="1"/>

 </Grid>

 


Paste commands work very nice, but i'm not able to use Cut or copy commands when i make a selection in the richtextbox. What's is wrong ?

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 31 Aug 2011, 04:42 PM
Hi Luc,

RadRichTextBox does not work with the ApplicationCommands in WPF. It has its own implementations of clipboard commands that support rich text copy and paste and are routed commands.
In order to use rich text copy/paste, you just have to add a reference to Telerik.Windows.Documents.FormatProviders.Html or ~.Rtf. After that, you can bind the RadMenuItems to the respective commands like this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <telerik:RadMenu DataContext="{Binding ElementName=radRichTextBox, Path=Commands}">
        <telerik:RadMenuItem Header="Edit">
            <telerik:RadMenuItem Header="Cut" Command="{Binding CutCommand}" />
            <telerik:RadMenuItem Header="Paste" Command="{Binding PasteCommand}"/>
        </telerik:RadMenuItem>
    </telerik:RadMenu>
    <telerik:RadRichTextBox Grid.Row="1" Name="radRichTextBox"/>
</Grid>

Regards,
Iva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

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