wpf - 文本框绑定(bind)到 LostFocus 和属性更新

标签 wpf xaml binding textbox prism

目前我绑定(bind)到我的TextBox即:

Text="{Binding DocValue,
         Mode=TwoWay,
         ValidatesOnDataErrors=True,
         UpdateSourceTrigger=PropertyChanged}"

这非常适合让每次击键都进行按钮状态检查(我想要的)。

另外,我想追踪LostFocus TextBox 上的事件(通过绑定(bind))并进行一些额外的计算,这些计算对于每次击键来说可能过于密集。

有人对如何实现两者有想法吗?

最佳答案

为了补充最高投票的答案,dotnet core 迁移了交互库。使其工作的步骤:

  1. Remove reference to "Microsoft.Expression.Interactions" and "System.Windows.Interactivity"
  2. Install the "Microsoft.Xaml.Behaviors.Wpf" NuGet package.
  3. XAML files – replace the xmlns namespaces "http://schemas.microsoft.com/expression/2010/interactivity" and "http://schemas.microsoft.com/expression/2010/interactions"with "http://schemas.microsoft.com/xaml/behaviors"
  4. C# files – replace the usings in c# files "Microsoft.Xaml.Interactivity" and "Microsoft.Xaml.Interactions" with "Microsoft.Xaml.Behaviors"


通过blog (Dec 2018) post here

关于wpf - 文本框绑定(bind)到 LostFocus 和属性更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15488033/

相关文章:

r - 在 for 循环中组合不同的矩阵

c# - System.Windows.MessageBox 与 System.Windows.Forms.MessageBox

c++ - UWP - ListView 绑定(bind)不显示在 C++/CX 中的 XAML 上

WPF TextBlock 动态粗体和斜体部分

c# - WPF 绑定(bind)顺序如何确保一个属性在另一个属性之前绑定(bind)

wpf - 命令执行对话框关闭后 MVVM UI 更新

c# - WPF InitializeComponent 性能问题

wpf - 在样式中,如何引用应用该样式的元素?

c# - WPF 改变对象的位置

c# - 您可以让扩展器覆盖 WPF 中的其他可视化树元素吗?