Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Event Notification
Message
De
01/12/2010 11:29:45
 
 
À
01/12/2010 10:24:31
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 4.0
Application:
Desktop
Divers
Thread ID:
01491399
Message ID:
01491412
Vues:
59
Hi Tim,

If I load a view and subscribe to the event, then another view is loaded and the event is subscribed again. Is this subscription additive? If I remove a view and unsubscribe, will it still be listening to the second view that also subscribed.

Yes, if events work the same in WPF as they do in WinForms ... I've not used WPF enough to know for sure, but that's the way it would work on a WinForm control.

~~Bonnie




>Hi All,
>
>This is probably not specifically a WPF question but I am working in WPF at the moment. I will take a stab at explaining what I am trying to do.
>
>I have a main window where I am adding user controls (views) dynamically. I am using an MVVM pattern and thus every view has a ViewModel class. The Main Window View Model keeps track of each view that is added dynamically and when it is closed and these are kept in a collection. Since I have the need to add a view from another view such as one form calling another form I need to notify the main window View Model via an event that I want to add another view. This event is implemented in a base class. so all views have the ability to raise the event notifying the main window ViewModel to add that view.
>
>Here is my question. If I add a view that can raise the event, I subscribe to the event at that time. But when the view is closed or removed from the collection I would need to unsubscribe to the event. This event is sort of generic so can it be subscribed multiple times? If I load a view and subscribe to the event, then another view is loaded and the event is subscribed again. Is this subscription additive? If I remove a view and unsubscribe, will it still be listening to the second view that also subscribed.
>Tim
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform