Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial MyUserControl()
- {
- InitializeComponent();
- Model.Initialize(DI.Resolve<IMyService>());
- Loaded += () => { Model.OnLoaded(); };
- Unloaded += () => { Model.OnUnloaded(); };
- }
- public class MyViewModel
- {
- private bool _isLoaded = false;
- private IMyService _myService;
- public MyViewModel() {
- // TODO: Add your constructor code here
- // The ctor is always called, initialize view model so that it also works in designer
- }
- public void InitializeIMyService myService) {
- _myService = myService;
- // TODO: Add your initialization code here
- // This method is only called when the application is running
- }
- public void OnLoaded() {
- if (!_isLoaded) {
- // TODO: Add your loaded code here
- _isLoaded = true;
- }
- }
- public void OnUnloaded() {
- if (_isLoaded) {
- // TODO: Add your cleanup/unloaded code here
- _isLoaded = false;
- }
- }
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement