-1

我正在尝试在 WPF 中编写一些行为。考虑以下代码片段:

<Button IsEnabled="{Binding Path=ButtonsAreEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">

有没有办法让我在不使用UpdateSourceTrigger的情况下实现以下行为:UpdateSourceTrigger=PropertyChanged}

我正在尝试将一些现有的 WPF 定义移植到Avalonia UI中,而Avalonia目前不支持UpdateSourceTrigger

我该怎么做?

谢谢,约翰B

4

1 回答 1

1

组合Mode=OneWayUpdateSourceTrigger=PropertyChanged是没有意义的。

UpdateSourceTrigger仅在 Bindings 中有效TwoWayOneWayToSource它控制何时准确更新 Binding 的源属性。

除此之外,设置Mode=OneWay是多余的,因为IsEnabled属性默认绑定OneWay

所以你的 Binding 表达式应该是这样的:

<Button IsEnabled="{Binding Path=ButtonsAreEnabled}">

甚至更短:

<Button IsEnabled="{Binding ButtonsAreEnabled}">
于 2020-02-13T06:12:16.003 回答