WPF 中的绑定更新顺序由什么定义?

发布于 2024-07-29 07:21:37 字数 485 浏览 3 评论 0原文

我有一段使用多个绑定的 WPF/C# 代码:

  1. 组合框用于选择帐户
  2. 第二个组合框的 itemssource 属性绑定到所选帐户。 第二个组合框用于选择联系人。
  3. 网格的 itemssource 属性绑定到所选帐户。 该网格包含选定的帐户发票。
  4. 联系人组合框父 DataContext 绑定到选定的发票。
  5. 联系人组合框的 SelectedItem 绑定到数据上下文中发票的 InvoiceContact 属性。

但是,绑定并未按照我希望的顺序更新。 当我选择另一个帐户时,“联系人”组合框的“ItemsSource”属性首先发生变化,然后它显然会更改“SelectedItem”,这会更改“InvoiceContact”,然后,选定的“发票”会发生变化...

无需说明它会弄乱所选的“发票” 。

如何控制更新绑定的顺序?

谢谢

亚历克斯

I have a piece of WPF/C# code that uses several Bindings:

  1. A combobox is used to select an Account
  2. The itemssource property of a second combobox is bound to the selected Account. This second combobox is used to select a Contact
  3. The itemssource property of a grid is bound to the selected Account. This grid contains the selected Account Invoices.
  4. The Contacts combobox parent DataContext is bound to the selected Invoice.
  5. The SelectedItem of the Contacts combobox is bound to the InvoiceContact property of the Invoice in the datacontext.

However the bindings are not updated in the order I want them to be. When I select another Account, the ItemsSource property of the Contact combobox change first, then it obviously change the SelectedItem, which changes the InvoiceContact and THEN, the selected Invoice changes...

No need to tell that it messes up the Invoice that was selected.

How can I control the order used to update the Bindings?

Thanks

Alex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

层林尽染 2024-08-05 07:21:37

您是否在类中实现 INotifyPropertyChanged 接口? 我认为如果你正常实现 INotifyPropertyChanged ,顺序并不那么重要

Are you implementing INotifyPropertyChanged interface in your classes? I think the order is not so important if you implement INotifyPropertyChanged normally

漫雪独思 2024-08-05 07:21:37

当我正要写一个答案(带有 PropertyChanged 的​​东西......)时,我意识到:
我不知道你在尝试什么。
所以我画了你的描述...
我真的不知道你在步骤 4 和 5 中尝试了什么。也许你可以详细说明一下?

As I was about to write an answer (something with PropertyChanged...) I realized:
I don't have a clue on what you're trying.
So I painted your description...
I really don't know what your trying in steps 4 and 5. Maybe you could elaborate ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文