Back to Devexpress

SimpleButton Class

wpf-devexpress-dot-xpf-dot-core-8b1a880d.md

latest10.7 KB
Original Source

SimpleButton Class

Serves as a base for classes that represent button controls.

Namespace : DevExpress.Xpf.Core

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
[DXLicenseWpfEditors]
public class SimpleButton :
    Button
vb
<DXLicenseWpfEditors>
Public Class SimpleButton
    Inherits Button

Remarks

The SimpleButton control is a standard System.Windows.Controls.Button descendant and supports all the inherited features.

Run Demo: Simple Button

Custom Button Content

Use the Content property to specify the SimpleButton ‘s content.

xaml
<dx:SimpleButton x:Name="simpleButton" Height="100" Width="226">
    <dx:SimpleButton.Content>
        <Grid>
            <Ellipse Height="80" Width="150" Fill="#FFAFAFF3"/>
            <TextBlock TextAlignment="Center" VerticalAlignment="Center" FontSize="30">Button</TextBlock>
        </Grid>
    </dx:SimpleButton.Content>
</dx:SimpleButton>

Customizable Glyph

Use the SimpleButton.Glyph property to assign a custom glyph.

  • Assign a glyph from the DXImage extension

  • Assign a glyph from the image file

Toggle Mode

Set the SimpleButton.ButtonKind property to Toggle to enable toggle mode.

Toggle mode supports two states, True and False. To enable the Indeterminate state, set the SimpleButton.IsThreeState property to true.

In toggle mode , the following events occur on mouse click:

Repeat Mode

In repeat mode , the Click event is repeatedly fired until a button is released.

Set the SimpleButton.ButtonKind property to Repeat to enable repeat mode.

Use the SimpleButton.Delay and SimpleButton.Interval properties to control the repeat behavior.

Asynchronous Mode

The SimpleButton control can indicate whether an asynchronous operation is in progress. To enable this behavior, set the SimpleButton.AsyncDisplayMode property to Wait or WaitCancel:

xaml
<dx:SimpleButton Content="Async Button" 
                 AsyncDisplayMode="WaitCancel" 
                 Command="{Binding AsyncCommand}"/>
csharp
using DevExpress.Mvvm;
using System.Threading.Tasks;
// ...

public class ViewModel : ViewModelBase {
    public IAsyncCommand AsyncCommand { get; }

    public ViewModel() {
        AsyncCommand = new AsyncCommand(AsyncMethod);
    }

    async Task AsyncMethod() {
        while(!AsyncCommand.IsCancellationRequested) {
            await Task.Delay(100);
        }
    }
}
vb
Imports DevExpress.Mvvm
Imports System.Threading.Tasks
' ...

Public Class ViewModel
    Inherits ViewModelBase

    Public ReadOnly Property AsyncCommand As IAsyncCommand

    Public Sub New()
        AsyncCommand = New AsyncCommand(AddressOf AsyncMethod)
    End Sub

    Private Async Function AsyncMethod() As Task
        While Not AsyncCommand.IsCancellationRequested
            Await Task.Delay(100)
        End While
    End Function
End Class

Refer to the following help topic for more information: Asynchronous Commands.

Customize Appearance

  1. Glyph, GlyphHeight, GlyphWidth
  2. Background, Foreground, FontSize
  3. Height, BorderBrush, BorderThickness, CornerRadius, Width
xaml
<Window ...
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core">
    <dx:SimpleButton Background="#FFE9EBEC" BorderThickness="2" BorderBrush="#FF0D3A50"
                     CornerRadius="5" Height="30" Width="150" Content="Upload" FontSize="10" 
                     Foreground="#ff505050" Glyph="{dx:DXImage SvgImages/Arrows/MoveUp.svg}" 
                     GlyphHeight="20" GlyphWidth="20"/>
</Window>

Tip

Refer to the following topic for more information: Appearance Customization.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SimpleButton class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-imageedit-edit-images-in-separate-window/CS/ImageEditToEditModeBehavior/EditImageWindow.xaml#L25

xml
<StackPanel Orientation="Horizontal" Margin="0,4">
    <dx:SimpleButton Command="{DXBinding '@e(editBehavior).UndoCommand'}"
                     Glyph="{dx:DXImage 'SvgImages/Icon Builder/Actions_Undo.svg'}"

wpf-create-a-fluent-design-using-appearance-options/CS/FluentDesignTemplate/MainWindow.xaml#L100

xml
</dxa:AccordionControl>
<dx:SimpleButton Grid.Row="1" CornerRadius="3" Foreground="White" Background="#BF60B5CC" Width="140" Height="40" Content="AI Assistant"/>
<TextBlock Grid.Row="2" HorizontalAlignment="Center" Foreground="#6DFFFFFF" FontFamily="Arial Rounded MT" Text="App v1.01" FontSize="8" Margin="20"/>

wpf-map-search-with-azure-map-search-service/CS/DXMapExample/MainWindow.xaml#L44

xml
</dxlc:LayoutItem>
<dx:SimpleButton Content="Search"
                 HorizontalAlignment="Right"

wpf-reporting-use-custom-controls-for-editing-report-content-in-print-preview/CS/MainWindow.xaml#L33

xml
<Grid>
    <dx:SimpleButton Content="Show Preview" Height="66" HorizontalAlignment="Left" Margin="174,106,0,0" Name="simpleButton1" VerticalAlignment="Top" Width="153" Command="{Binding ShowPreviewCommand}" />
    <!--<dx:SimpleButton Content="Show Designer" Height="66" HorizontalAlignment="Left" Margin="172,0,0,81" Name="simpleButton2" VerticalAlignment="Bottom" Width="153" Command="{Binding ShowDesignerCommand}" />-->

wpf-richedit-use-document-iterator-and-visitor/CS/DocumentIteratorExample/MainWindow.xaml#L12

xml
<StackPanel Width="280">
    <dx:SimpleButton Height="25"
                     Margin="5,20,5,0"

Inheritance

Show 15 items

Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control ContentControl ButtonBase Button SimpleButton DropDownButtonBase

ThemedWindowDialogButton

DropDownButton

SplitButton

See Also

SimpleButton Members

DevExpress.Xpf.Core Namespace