|
-
Jan 5th, 2010, 04:05 PM
#1
Thread Starter
Frenzied Member
An MVVM Question
Hi guys, I am currently learning MVVM and have a few questions for anyone who has taken the time to look it up.
The first is this thing of passing classes to other classes, any of the video examples I have seen do something like this:
Code:
public class viewModel
{
readonly dataModel _model;
public viewModel (dataModel model)
{
_model = dataModel;
}
}
and then they proceed to databind to the viewmodel properties but if the class is read only how do they send data back to it? Is it just a case that they are not sending back data in that instance?
-
Jan 5th, 2010, 04:33 PM
#2
Re: An MVVM Question
I'm not sure if this helps and you might already know this but I'll explain anyway: Just because a property/variable is read only, does not mean you cannot modify it It simply means that you cannot replace the entire object that the property is holding. You can still access the properties of that object and modify them (if you didnt want that to be possible then you would have to make the properties read-only as well)
For example:
vb Code:
Private ReadOnly MyTcpClient As New Net.Sockets.TcpClient
Private Sub SomeMethod()
'This works, as we are modifying a property of the TcpClient that the variable refers to
MyTcpClient.NoDelay = False
'This does not, as we are trying to replace the entire object reference
MyTcpClient = New Net.Sockets.TcpClient
End Sub
-
Jan 5th, 2010, 05:08 PM
#3
Thread Starter
Frenzied Member
Re: An MVVM Question
Ok that makes sense but if your are not instantiating does that mean you are accessing the same one?
-
Jan 5th, 2010, 06:02 PM
#4
-
Jan 5th, 2010, 06:09 PM
#5
Thread Starter
Frenzied Member
Re: An MVVM Question
Oh I dunno, Im lost, walking and running come to mind, im going back to basics and taking out my C#2008 and the 3.5 platform book. Its annoying that its stuff like this that gets me yet I have no problem cracking open XPS files and reading them ggrrrr!
Thanks for the help chris!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|