简体   繁体   English

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

[英]Vb.Net Child Class sending Events to Parent Class

I have a class that is used to handle ItemList based objects and is bound to the controls on WPF. 我有一个用于处理基于ItemList的对象的类,并且该类绑定到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. 当用户选择一个值时,我可以在该类中看到它,但是我需要将一个事件发送给该选择已更改的父viewmodel类,因为父级正在处理所有其他控件更新。 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. 一个事件似乎是我所需要的,但是作为一个新手,并且只对VB有点熟悉,因此我无法遵循任何涉及routedevents或委托的示例。 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). 我有另一种类似的情况,我有一个可观察的字段集合,该字段由单个集合行引用映射到XAML网格,并且我需要在父级别知道某个集合字段类何时发生值更改(我看到了类设置器中的更改)。 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). 我需要确切地看到我应该在父类和子类中都放置什么内容来注册和调用事件,并且我需要在VB中(使用.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. 谢谢你的帮助。

Answered myself. 回答自己。 Be nice if MSDN help dealt with collections on events. 如果MSDN帮助处理事件集合,那就更好了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM