Catel Mapping properties to Model

180 views Asked by At

I have problem with AutoMapping Catel ViewModel -> Model properties.

I'm using Catel with Fody.Catel

I have a situation when my model changes during runtime.

My Model declaration looks like this:

[Model]
public MyModel SelectedMyModel { get; set; }

And I change this model during runtime like this:

private void TabChangedHandler(TabChangedMessage tabChangedMessage)
{
    SelectedMyModel = (MyModel) tabChangedMessage.Data;
}

Then, I'm delegating some properties from Model to ViewModel like this:

[ViewModelToModel("SelectedMyModel")]
public string Name { get; set; }

[ViewModelToModel("SelectedMyModel")]
public string LastName { get; set; }

And the problem is:

When I'm setting this property for the first time, it works nice, but If I change SelectedMyModel to another object, it stops working.

Looks like delegation ViewModel -> Model is no longer working.

Should I call something to let Catel know, that my Model is changing? Or maybe it's a Catel issue?

Can you please help me?

0

There are 0 answers