Clear the screen using a new instance

Jan 10, 2012 at 7:23 PM

Hello guys. I really enjoyed the purpose of this framework.

OK. Let's go to my doubt.


I'm trying to make a CRUD Window using the framework.

When the user click on my "New User" button, I want to clear my controls, allowing a new typing, but I want to do that by clearing my background "User" object (as in the following ViewModel Snippet):

 

    public class UserFormModel : MicroModel
    {
        private User user;

        public UserFormModel()
        {
            user = new User();

            Property(() => user.id);
            Property(() => user.login);
            Property(() => user.password);

            Command("NewUser", () => NewUser());
        }

        public void NewUser()
        {
            user = new User();
        }
    }

But when I do this "user = new User();" in the "NewUser()" method, the "this.user" object is no longer bound to the view. I can understand this, because the object I'm working now isn't the same that is bound to the view. The view still using the "old" (and populated) object, but I want it to use the new (and empty) one.

Sorry if I made any English mistake. I'm Brazilian and I'm not thaaaat English fluent. Could you understand me?

Thanks.

Diego Stiehl.

Jan 14, 2013 at 7:25 PM
Edited Jan 14, 2013 at 7:30 PM

Hi Diego

I've only just found this framework myself but I believe your problem is because you are not raising a property changed notifications after you change the underlying model.  I found a comment on this page that should help you out.  The comment was by 'xxxprod' on 28 Sep, 2010. Good luck!

Edit: next time I'll check the year when I post...

Ben