Skip to main content

EditBase.ErrorIconCommand Property

Gets or sets the command executed when a user taps the error icon. This is a bindable property.

Namespace: DevExpress.Maui.Editors

Assembly: DevExpress.Maui.Editors.dll

NuGet Package: DevExpress.Maui.Editors

Declaration

public ICommand ErrorIconCommand { get; set; }

Property Value

Type Description
ICommand

The command that exposes the ICommand interface.

Remarks

Use the ErrorIconCommand property to set the action that occurs when a user taps the error icon. The ErrorIconCommandParameter property allows you to pass data to ErrorIconCommand.

You can also use the ErrorIconClicked event to define the action on error icon tap.

Example

This example shows how to create a custom command with a parameter and execute it when a user taps the start icon.

Icon Command Example

  1. In a view model, create a command that implements the ICommand interface:

    using System.ComponentModel;
    using System.Windows.Input;
    
    namespace TestICommand.ViewModels {
        public class CopyCommand : ICommand {
            public event EventHandler CanExecuteChanged;
    
            MainViewModel viewModel;
            public CopyCommand(MainViewModel viewModel) {
                this.viewModel = viewModel;
            }
    
            public bool CanExecute(object Login) {
                return true;            
            }
    
            public void Execute(object Login) {
                viewModel.LoginText = viewModel.NameText;
            }
        }
    
        public class MainViewModel : INotifyPropertyChanged {
            public MainViewModel() {
                iconCommand = new CopyCommand(this);
            }
    
            ICommand iconCommand = null;
            public ICommand IconCommand {
                get { return iconCommand; }
                set { 
                    if (iconCommand != value) {
                        iconCommand = value;
                        OnPropertyChanged("IconCommand");
                    }
                }
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged(string name) {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
            }
    
            string loginText = "";
            public string LoginText {
                get { return loginText; }
                set {
                    loginText = value;
                    OnPropertyChanged("LoginText");
                }
            }
    
            string nameText = "";
            public string NameText {
                get { return nameText; }
                set {
                    nameText = value;
                    OnPropertyChanged("NameText");
                }
            }
        }
    }
    
  2. Bind the specified command to the StartIconCommand property and define the StartIconCommandParameter value:

    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:local="clr-namespace:TestICommand"
            xmlns:vm="clr-namespace:TestICommand.ViewModels"
            x:Class="TestICommand.MainPage"
            xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors">
        <ContentPage.BindingContext>
            <vm:MainViewModel/>
        </ContentPage.BindingContext>
        <StackLayout>
            <dxe:TextEdit x:Name="NameEditor" 
                          Text="{Binding NameText}"
                          LabelText="First Name"/>
    
            <dxe:TextEdit x:Name="LoginEditor" 
                          Text="{Binding LoginText}" 
                          LabelText="Login" 
                          StartIcon="icon" 
                          StartIconCommand="{Binding IconCommand}" 
                          StartIconCommandParameter="{Binding Source={x:Reference NameEditor}, Path=Text}"
                          HelpText="Tap the icon to use your first name as login"/>
        </StackLayout>
    </ContentPage>
    
See Also