If you can edit something, then there must be a modified container for an immutable value. Therefore, your view model should act directly in a mutable container, and not on an immutable value.
An integer is an example of such an immutable value object: the type Int32has no members that allow you to change the state of the object. You can replace an integer rather than change it. Thus, the view model for the whole will look like this:
public MutableIntegerViewModel
{
private readonly mutableInteger;
public MutableIntegerViewModel(MutableInteger mutableInteger)
{
this.mutableInteger = mutableInteger;
}
public string DisplayText
{
get
{
return this.mutableInteger.Value.ToString(
CultureInfo.CurrentCulture);
}
set
{
this.mutableInteger.Value =
Int32.Parse(value, CultureInfo.CurrentCulture);
}
}
}
Where MutableIntegeris it only:
public class MutableInteger
{
public int Value { get; set; }
}
I forgot about error handling and change notification here, but hopefully you get this idea.
, Customer FirstName a LastName. , .