Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DXEvent

DXEvent is used when you need to define methods that should be called on an event.

Similar to DXBinding and a standard Binding, DXEvent works with the DataContext object by default.

<StackPanel>
    <StackPanel.DataContext>
        <local:ViewModel />
    </StackPanel.DataContext>
    <Button Content="OK" Loaded="{DXEvent Handler='Initialize()'}" />
    <Button Content="OK" Loaded="{DXEvent Handler='Initialize(); Load()'}" />
</StackPanel>
public class ViewModel {
    public void Initialize() { }
    public void Load() { }
}

The Handler expression is specified with a special language that is described in the following topic: Language Specification.

You can pass any parameter to the calling methods.

<TextBlock x:Name="tb" Text="text"/>
<Button Content="OK" Loaded="{DXEvent Handler='Initialize(@e(tb).Text)'}"/>
public void Initialize(string arg) { }

To access the event sender and event arguments, use the @sender and @args reserved words.

<TextBlock x:Name="tb" Text="text"/>
<Button Content="OK" Loaded="{DXEvent Handler='Initialize(@sender.Content, @args, @e(tb).Text)'}"/>
public void Initialize(object content, RoutedEventArgs args, string text) { }

The DXEvent extension supports the “=“ operator.

<Button Click="{DXEvent '@e(checkBox).IsChecked=true'}"/>

Note

DXEvents cannot be used in EventSetters.