Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I binding xaml event from WPF in .net core 3.0?

How should I binding a event in netcore 3.0? In a WPF project(netcore3.0), there is no kind of Interactive.dll to do like

<i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseDoubleClick">
        <i:InvokeCommandAction Command="{Binding Path=DoSomethingCommand}"/>
    </i:EventTrigger>
</i:Interaction.Triggers>

so how to binding a event in WPF (netcore3.0)?

like image 916
ByByeBye Avatar asked Mar 04 '23 23:03

ByByeBye


1 Answers

You should be able to use a mousebinding for this.

  <YourControl.InputBindings>
      <MouseBinding MouseAction="LeftDoubleClick" Command="... />
  </YourControl.InputBindings>

The way you're intended to use that dll now is via a nuget package - xaml bahaviors.

https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/

Seeing as how net core 3 is still only in preview, i thought it might be rather early for this package to be updated.

Seems not though:

https://github.com/microsoft/XamlBehaviorsWpf/issues/13

like image 99
Andy Avatar answered Mar 07 '23 01:03

Andy