Blogs

The One With

WPF Rich Edit Control and WPF Ribbon (coming in v2010 vol 2)

     

For the v2010 vol 2 release, we have tremendously improved how the Rich Edit Control interacts with our Toolbar-Menu System.

Watch how to create a Ribbon based text editor in just under one minute in WinForms.

WinForms Text Editor in under a minute

These improvements carried over to the new WPF Rich Edit control as well.

WPF Rich Edit Control and WPF Ribbon

To associate Ribbon items with the Rich Edit Control, all you have to do is bind them to the corresponding editor commands and they will automatically behave correctly. Even the UI attributes such as Icons and Captions will be generated for you automatically.

Sample XAML:

 <dx:DXWindow.Resources>
        <ResourceDictionary>
            <dxre:RichEditUICommand x:Key="commands" />
        </ResourceDictionary>
 </dx:DXWindow.Resources>

 <Grid>
        <
dxb:BarManager Name="barManager1" ToolbarGlyphSize="Small">
            <
dxb:BarManager.Items>
                <
dxb:BarButtonItem
                   
Command="{Binding Path=FileNew, Mode=OneTime, Source={StaticResource commands}}"
                   
CommandParameter="{Binding ElementName=richEdit}"
                   
Name="biFileNew"/>
                <
dxb:BarButtonItem
                   
Command="{Binding Path=FileOpen, Mode=OneTime, Source={StaticResource commands}}"
                   
CommandParameter="{Binding ElementName=richEdit}"
                   
Name="biFileOpen"/>
                <
dxb:BarButtonItem
                   
Command="{Binding Path=FileSaveAs, Mode=OneTime, Source={StaticResource commands}}"
                   
CommandParameter="{Binding ElementName=richEdit}"
                   
Name="biFileSaveAs"/>
            </
dxb:BarManager.Items>
            <
dx:DXDockPanel>
                <
dxr:RibbonControl dx:DXDockPanel.Dock="Top" x:Name="ribbonControl">
                    <
dxr:RibbonDefaultPageCategory>
                        <
dxr:RibbonPage Caption="File" Name="pageFile">
                            <
dxr:RibbonPageGroup Caption="Common" Name="grpCommon">
                                <
dxb:BarButtonItemLink BarItemName="biFileNew" />
                                <
dxb:BarButtonItemLink BarItemName="biFileOpen" /> <dxb:BarButtonItemLink BarItemName="biFileSaveAs" />
                            </
dxr:RibbonPageGroup>
                        </
dxr:RibbonPage>
                    </
dxr:RibbonDefaultPageCategory>
                </
dxr:RibbonControl>
                <
dxre:RichEditControl
                   
x:Name="richEdit"
                   
BarManager="{Binding ElementName=barManager1, Mode=OneTime}"></dxre:RichEditControl>
            </
dx:DXDockPanel>
        </
dxb:BarManager>
    </
Grid>

Notice that I did not have to assign icons and handle the item click events myself. All I had to do was bind my Ribbon items to a specific Rich Editor command and that’s it.

<dxb:BarButtonItem 
    Command="{Binding Path=FileNew, Mode=OneTime, Source={StaticResource commands}}" 
    CommandParameter="{Binding ElementName=richEdit}" 
    Name="biFileNew"/>

Pretty cool ah?

Cheers

Azret

Published Oct 22 2010, 04:34 PM by Azret Botash (DevExpress)
Technorati tags: v2010.2, DXRichEdit, XtrarRichEdit
Bookmark and Share

Comments

No Comments
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.