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


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.

        <local:ViewModel />
    <Button Content="OK" Loaded="{DXEvent Handler='Initialize()'}" />
    <Button Content="OK" Loaded="{DXEvent Handler='Initialize(); Load()'}" />
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'}"/>