|
-
Jan 5th, 2010, 04:09 PM
#1
Thread Starter
Frenzied Member
Does WPF have a place to store data?
I have been learning about MVVM and it seems to make sense, mostly! One of the things I notice is that the idea is that a model is a place that gets data be it from a database or webservice or other applicable place.
What i want to know is what if the data is so small you only what it in memory is there a way for one to save in memory outside the instantiation of a particular model? That way the models that need to use this data can access this store when instantiated and their destruction would not kill of the store!
-
Jan 5th, 2010, 04:25 PM
#2
Re: Does WPF have a place to store data?
As you already know, I dont have much knowledge about MVVM, but to me it seems like all you are really wanting to do is just keep some data in memory and have several classes be able to access that data. So cant you just have a separate class that holds this data in Shared objects? I dont know what sort of data you are talking about but if it was just a List(Of String) or something then you could just have something like:
vb Code:
Public Class DataStorage
Public Shared DataList As New List(Of String)
End Class
Then whenever you wanted to load data into (or remove data from) that list then you just refer to it like so:
vb Code:
DataStorage.DataList.Add("a new string")
or am I missing something?
-
Jan 5th, 2010, 05:10 PM
#3
Thread Starter
Frenzied Member
Re: Does WPF have a place to store data?
No no that makes sense so if I have this right the class is instantiated but the information which is static (shared) is not therefore keeps its values?
-
Jan 5th, 2010, 06:00 PM
#4
Re: Does WPF have a place to store data?
Well no you dont need to instantiate the class, that is the point of Shared/Static - you can access Shared/Static objects without an instance of the class that they are in
-
Jan 5th, 2010, 06:02 PM
#5
Thread Starter
Frenzied Member
Re: Does WPF have a place to store data?
Oh I see, and what about just declaring a class in the app.xaml.cs? Afterall the data is related to the application and this would give other classes access right?
-
Jan 5th, 2010, 06:05 PM
#6
Re: Does WPF have a place to store data?
I'm not sure how the app.xaml.cs works, is it just like a place that any code in the application can access? I'm not 100% sure whether you can actually define a class within it - Personally I would just create a new class file for it
-
Jan 5th, 2010, 06:07 PM
#7
Thread Starter
Frenzied Member
Re: Does WPF have a place to store data?
Tested it it doesn't work...
Im going to have to read up on static objects cause how I think they work and how they actually work seem to be different!
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
|