.net - Difference between datacontext and normal object creation in C# -
i have seen video @ different windows, presenter follows different styles.
for instance:
in 1 window, uses below:
employeeviewmodel evm = (employeeviewmodel)this.datacontext; evm.display();
in another, uses like:
employeeviewmodel evm = new employeeviewmodel(); evm.display();
whats difference technically , best way use ? please me understand difference.
the first code fragment retrieves displayed viewmodel. (it should null-check)
the second code fragment creates new instance of viewmodel.
because not clear display() does, hard explain difference between effect of 2 fragments second fragment (unit)test of viewmodel ignores view.
there no best way far can see because both fragments serve different purpose.
Comments
Post a Comment