Vb.Net 子类向父类发送事件

发布于 2024-10-22 00:55:56 字数 401 浏览 4 评论 0原文

我有一个类,用于处理基于 ItemList 的对象,并绑定到 WPF 上的控件。当用户选择一个值时,我可以在类中看到它,但我需要向父视图模型类发送一个事件,表明选择已更改,因为父级正在处理所有其他控件更新。我将有不同的父类类型,因此不可能将父类声明为子类中的特定类型。一个事件似乎是我所需要的,但作为一个新手并且只对 VB 有点熟悉,我无法遵循任何处理路由事件或委托的示例。我有另一个类似的情况,其中我有一个可观察的字段集合,该集合由单个集合行引用映射到 XAML 网格,并且我需要在父级别知道其中一个集合字段类何时发生值更改(我看到类设置器的更改)。同样,需要某种事件来通知父级更改。 我需要准确地了解应该在父类和子类中放入什么来注册和调用事件,并且我需要在 VB 中(使用 .net4)。任何描述性注释将不胜感激。我知道这可能很简单,但我在试图阅读地图时陷入了困境。感谢您的任何帮助。

I have a class that is used to handle ItemList based objects and is bound to the controls on WPF. When a user selects a value, I can see that in the class, but I need to send an event to the parent viewmodel class that the selection has changed, as the parent is handling all the other control updates. I will have different parent class types, so declaring the parent as a specific type in the child is not possible. An event appears to be what I need, but as a newbie and only somewhat familiar with VB, I have not been able to follow any of the examples dealing with either routedevents or delegates. I have another similar case where I have an observable collection of fields that is mapped by individual collection row reference to a XAML grid, and I need to know at the parent level when one of the collection field classes has a value change (I see the change in the class setters). Again, some sort of event is needed to notify the parent of the change.
I need to see exactly what I should put in both the parent and the child classes to register and call the events and I need it in VB (using .net4). Any descriptive notes would be greatly appreciated. I know this may be simple, but I am neck deep in the swamp trying to read the map. Thanks for any help.

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

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

发布评论

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

评论(1

你列表最软的妹 2024-10-29 00:55:56

我自己回答道。如果 MSDN 能帮助处理事件集合,那就太好了。

Answered myself. Be nice if MSDN help dealt with collections on events.

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