Breaking Change T920147
Visible to All Users

Specific events have changed their delegate type from Action to EventCallback

What Changed

We changed the delegate type from Action to EventCallback for the following events:

Reasons for Change

In previous versions, you had to call the StateHasChanged method in an event handler to rerender a component after changes. The EventCallback delegate contains a reference to its bound component and calls the StateHasChanged method automatically. So, you no longer need to care about component rerendering and complicate your code.

Razor
<DxButton ...Click="@Like"> @code { int likes = 1; void Like(MouseEventArgs args) { likes++; // InvokeAsync(StateHasChanged); You no longer need to call this method. } }

The *Changed events listed above now automatically update the corresponding properties if you use a two-way binding (the @bind attribute). You can simplify your code as follows:

Razor
<DxSpinEdit @bind-Value="@DecimalValue"></DxSpinEdit> @code { // Old version: // Decimal decimalValue = 15; // Decimal DecimalValue { get => decimalValue; // set { decimalValue = value; InvokeAsync(StateHasChanged); } } // New version: Decimal DecimalValue { get; set; } = 15; }

The EventCallback delegate is also more convenient when you do not need to pass event parameters. Even if an event has the EventCallback<ChangeEventArgs> signature, you can implement event handlers without parameters.

Impact on Existing Apps

These changes will affect your application in the following cases:

  1. If you handle an event that now uses the EventCallback<T> delegate.
Razor
<DxSpinEdit Value="@NumericValue" ValueChanged="@((newValue) => OnValueChanged(newValue))" /> <DxDateEdit Date="@Date" DateChanged="@((newValue) => OnDateChanged(newValue))" />
  1. If you handle the DxFormLayout.ItemUpdating event.
Razor
<DxFormLayout ... ItemUpdating="@((fieldName, newValue) => OnItemUpdating(fieldName, newValue))"> </DxFormLayout>
  1. If you handle any of the listed events in C# code via RenderTreeBuilder (instead of the Razor markup).
C#
builder.OpenComponent<DxCheckBox<T>>(0); builder.AddAttribute(1, "CheckedChanged", new Action<T>((newValue) => onValueChanged(newValue)));

How to Update Existing Apps

  1. If an event uses the EventCallback<T> delegate, specify the component data type explicitly.
Razor
<DxSpinEdit Value="@NumericValue" ValueChanged="@((int newValue) => OnValueChanged(newValue))" /> <DxDateEdit Date="@Date" DateChanged="@((DateTime newValue) => OnDateChanged(newValue))" />
  1. Handle the DxFormLayout.ItemUpdating event as follows:
Razor
<DxFormLayout ... ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))"> </DxFormLayout>
  1. Handle an event in C# code in the way shown below:
C#
builder.OpenComponent<DxCheckBox<T>>(0); builder.AddAttribute(1, "CheckedChanged", EventCallback.Factory.Create<T>(context.Receiver, (newValue) => context.OnChanged(newValue)));

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.