Binding UserControl unload event to ViewModel
I'm reasonable new to MVVM and have a usercontrol as my View. I'd like to Bind the "unload" event of that control to a method in my ViewModel. To clean up stuff when the control is shutting down.
My search so far has only come up with xamples that require you to include some kind of toolkit or libraries from expression blend SDK. I j开发者_Go百科ust want to use he generic .net 4.1 libraries.
Can some one show me how to accomplish this ?
I've always used the code shown here to create an AttachedCommandBehavior
. It doesn't require any extra libraries and can be used like this:
<local:MyControl
local:CommandBehavior.Event="Unloaded"
local:CommandBehavior.Command="{Binding ViewModelUnloadedCommand}" />
精彩评论