Вопрос

I 've seen many WP7 applications, some place event handlers in code, some place event handlers in XAML

Should we add event handler in XAML?

Does that handler automatically unsubscribe to the event when the page is navigated from ?

Это было полезно?

Решение

You can do either, it really doesn't matter! And no, you do not have to worry about adding / removing event handlers when the user navigates from one page to the next. When a page is no longer needed, it is destroyed.

The only time you might want to handle things differently is if you are using the MVVM pattern, when you might want to use commands rather than event handlers.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top