A newer version of this page is available. Switch to the current version.

ButtonEdit Class

Represents a text editor with embedded buttons.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v19.1.dll


public class ButtonEdit :

The following members accept/return ButtonEdit objects:


ButtonEdit editors are text editors which allow you to display an unlimited number of buttons within the edit box.



The ButtonEdit class inherits its features from the TextEdit class.

Refer to the TextEdit class description for information on derived features and API.

Create a ButtonEdit

The editor’s value can be specified using the BaseEdit.EditValue or TextEditBase.Text property.

<Window ...

<!-- Specify value using the TextEditBase.Text property -->
<dxe:ButtonEdit Text="Hello World!"/>

<!-- Specify value using the BaseEdit.EditValue property -->
<dxe:ButtonEdit EditValue="Hello World!"/>

To respond to changing the editor’s value, handle the BaseEdit.EditValueChanged event. To check the new value’s validity, handle the BaseEdit.Validate event.

Embedded Buttons

Default Button

The editor displays one button by default (the default button). The default button visibility is specified by the ButtonEdit.AllowDefaultButton property.

When an end user clicks the default button, the editor fires the ButtonEdit.DefaultButtonClick event.

<dxe:ButtonEdit x:Name="buttonEdit1"

Custom Buttons

To display more buttons, create ButtonInfo objects, and add them to the ButtonEdit.Buttons collection.

    <dxe:ButtonInfo GlyphKind="Undo" Command="ApplicationCommands.Undo"/>
    <dxe:ButtonInfo GlyphKind="Redo" Command="ApplicationCommands.Redo"/>

To respond to clicking a custom button, handle its ButtonInfo.Click event or specify a command.

Retrieve Buttons from ViewModel

You can load a set of custom buttons from a ViewModel and display them in the ButtonEdit. Use the ButtonEdit.ButtonsSource property to specify a collection of objects providing information to generate and initialize buttons for the current ButtonEdit. The ButtonTemplate property specifies the data template used to render buttons from the collection.

                Command="{Binding Command}"
                Content="{Binding Content}"
                IsLeft="{Binding IsLeft}" />

If you want to declare several data templates and apply one of them according to your own logic, use the ButtonEdit.ButtonTemplateSelector property.

Look and Feel

If the ShowText property is set to false, the edit box is hidden and only editor buttons are displayed (see the image below). If no buttons are visible, the editor displays an empty region.


The ShowEditorButtons property specifies whether the editor should display its buttons.

Edit Options

Set the IsTextEditable property to false to prevent end users from editing an editor’s text values.

If the IsTextEditable property is set to false, end users are not allowed to change, select and copy the text displayed in the edit box, but can click editor buttons (if any).

Delete Button

End users can clear an editor value using a null value button.

You can use any of the following ways to add the delete button.

  1. Set the ButtonEdit.NullValueButtonPlacement (or the ButtonEditSettings.NullValueButtonPlacement for the in-place ButtonEdit) property to EditorPlacement.EditBox to display the delete button in the editor’s edit box.


  1. Add a DeleteButtonInfo class instance to the editor’s ButtonEdit.Buttons (ButtonEditSettings.Buttons for the in-place ButtonEdit) collection. In this case, you can fully customize the delete button’s behavior and appearance. To set the default button’s behavior, set the DeleteButtonInfo.IsDefault property to true.


The following example shows how to create a ButtonEdit with the Clear button that clears the editor's value.

using System.Windows;

namespace ButtonEdit_Creating {
    public partial class Window1 : Window {
        public Window1() {
        private void ButtonInfo_Click(object sender, RoutedEventArgs e) {
            buttonEdit.EditValue = string.Empty;
See Also