MVVM Light field and specified data model

Here is a basic diagram for using the MVVM Light method Set

:

public class MyViewModel : ViewModelBase
{
    private string _text;
    public Text 
    {
        get{ return _text; }
        set{ Set(()=>Text, ref _text, value); }
    }        
}

      

But in my project, I keep the fields in the DataModel class, which is good for cloning data and copies to undo changes:

public class MyDataModel
{
    public string Text;
}

public class MyViewModel : ViewModelBase
{
    private MyDataModel data;
    public Text 
    {
        get{ return data.Text; }
        set{ data.Text = value; RaisePropertyChanged(()=>Text); } 
    }        
}

      

But in this case I cannot use the method Set

because its the second parameter ref

and I cannot use it data.Text

as a parameter ref

.

Set( ()=>Text, ref data.Text, value ); // - its error

      

Any thoughts on how to fix this issue are greatly appreciated.

+3


source to share





All Articles