Back to Devexpress

RichEditControl.CommandProvider Property

wpf-devexpress-dot-xpf-dot-richedit-dot-richeditcontrol-bad6171f.md

latest5.9 KB
Original Source

RichEditControl.CommandProvider Property

Gets or sets a RichEditControl’s command provider. This is a dependency property.

Namespace : DevExpress.Xpf.RichEdit

Assembly : DevExpress.Xpf.RichEdit.v25.2.dll

NuGet Package : DevExpress.Wpf.RichEdit

Declaration

csharp
public CommandProvider CommandProvider { get; set; }
vb
Public Property CommandProvider As CommandProvider

Property Value

TypeDescription
DevExpress.Xpf.RichEdit.CommandProvider

A DevExpress.Xpf.RichEdit.CommandProvider object.

|

Remarks

A command provider stores commands used by the integrated ribbon. You can use it to assign a command to a command bar item, as described in the table below.

This example demonstrates how to customize the RichEdit’s integrated Ribbon UI. The tasks and required property settings are listed in the table.

|

Task

|

Property Setting

| | --- | --- | |

Use integrated Ribbon UI

|

Set the RichEditControl.CommandBarStyle property to the CommandBarStyle.Ribbon value.

| |

Load a document

|

Specify the RichEditControl.DocumentSource property. The DXBinding extension allows you to call a method that returns a valid document source directly in XAML.

| |

Determine the ribbon item name

|

Element names are the fields of the DevExpress.Xpf.RichEdit.DefaultBarItemNames class. However, you can easily deduce the required element name by following simple naming rules as demonstrated in the table below.

|

Item

|

Item Type

|

Page Name

|

Group Name

|

Item Name

|

DefaultBarItemNames Field

| | --- | --- | --- | --- | --- | --- | |

|

RibbonItem

|

File

|

Info

|

Document Properties

|

RibbonItem_File_Info_DocumentProperties

|

| |

Remove a command bar item.

|

Add a new RemoveAction to the RichEditControl.RibbonActions collection.

| |

Modify a command bar item.

|

Add a new UpdateAction to the RichEditControl.RibbonActions collection. Set the UpdateAction.PropertyName attribute to the name of the property you wish to change, the UpdateAction.Value attribute is the new property value.

| |

Insert a command bar item.

|

Add a new InsertAction to the RichEditControl.RibbonActions collection.

| |

Create a command to assign to the command bar item.

|

To obtain a command for binding, specify the CommandProvider object’s field which has the same name as the command. The CommandProvider object is accessible using the RichEditControl.CommandProvider property. To get access to the RichEditControl in binding syntax, use the RichEditControl.RichEdit property.

|

Example

xaml
<dxre:RichEditControl Name="richEditControl1" CommandBarStyle="Ribbon" DocumentSource="{DXBinding '$local:SourceHelper.GetDocumentSource()'}">
    <dxre:RichEditControl.RibbonActions>
        <dxb:RemoveAction ElementName="{x:Static dxre:DefaultBarItemNames.RibbonPage_Review}"/>
        <dxb:RemoveAction ElementName="{x:Static dxre:DefaultBarItemNames.RibbonGroup_PageLayout_PageBackground}"/>
        <dxb:RemoveAction ElementName="{x:Static dxre:DefaultBarItemNames.RibbonItem_File_Info_DocumentProperties}"/>
        <dxb:RemoveAction ElementName="{x:Static dxre:DefaultBarItemNames.RibbonPage_Review}"/>
        <dxb:RemoveAction ElementName="{x:Static dxre:DefaultBarItemNames.RibbonPage_MailMerge}"/>
        <dxb:UpdateAction ElementName="{x:Static dxre:DefaultBarItemNames.RibbonPage_View}" PropertyName="IsSelected" Value="True"/>
        <dxb:InsertAction Index="2" ContainerName="{x:Static dxre:DefaultBarItemNames.RibbonPage_View}">
            <dxr:RibbonPageGroup Caption="Demo">
                <dxb:BarButtonItem Content="About"
                                   LargeGlyph="{dx:DXImageOffice2013 Image=Info_32x32.png}"
                                   ItemClick="About_ItemClick"/>
            </dxr:RibbonPageGroup>
        </dxb:InsertAction>
        <dxb:InsertAction Index="7" ContainerName="{x:Static dxre:DefaultBarItemNames.RibbonPage_Insert}">
            <dxr:RibbonPageGroup Caption="Comments">
                <dxb:BarButtonItem Content="Comment"
                                   LargeGlyph="{dx:DXImage Image=NewComment_32x32.png}"
                                   Command="{Binding RelativeSource={RelativeSource Self}, Path=(dxre:RichEditControl.RichEdit).CommandProvider.NewComment}"/>
            </dxr:RibbonPageGroup>
        </dxb:InsertAction>
    </dxre:RichEditControl.RibbonActions>
</dxre:RichEditControl>

See Also

RichEditControl Class

RichEditControl Members

DevExpress.Xpf.RichEdit Namespace