【问题标题】:How should I binding xaml event from WPF in .net core 3.0?我应该如何在 .net core 3.0 中绑定来自 WPF 的 xaml 事件?
【发布时间】:2019-10-09 23:45:10
【问题描述】:

我应该如何在 netcore 3.0 中绑定事件? 在 WPF 项目(netcore3.0)中,没有类似的 Interactive.dll

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

那么如何在 WPF (netcore3.0) 中绑定事件呢?

【问题讨论】:

  • 使用支持 .NET Core 的实现,例如 Prism 7.2.0.1233 的预览版。
  • 在快速浏览了 Prism 的概述和文档后,似乎不存在处理它的方法。
  • 什么意思?您应该能够在 .NET Core 应用中简单地安装 NuGet 包的预览版。
  • 已经安装了prism预览版,只是不知道怎么编码..绑定事件..
  • 到目前为止你尝试过什么?哪些有效,哪些无效?

标签: c# wpf xaml .net-core binding


【解决方案1】:

您应该可以为此使用鼠标绑定。

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

您现在打算使用该 dll 的方式是通过 nuget 包 - xaml bahaviors。

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

鉴于 net core 3 仍处于预览阶段,我认为更新此软件包可能还为时过早。

似乎没有:

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

【讨论】:

    猜你喜欢
    • 2018-11-09
    • 1970-01-01
    • 2020-01-24
    • 2020-03-09
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    • 2010-12-26
    • 2015-12-10
    相关资源
    最近更新 更多