Reputation: 3506
I want to build a WP7 app. I already have most of the logic written, but i'm not sure how i would go about and build a wp7 silverlight app that uses that logic.
The already written logic consists of a few simple models and there is no silverlight specific stuff like observablecollections of inotifypropertychanged.
How would you go about creating a app from an existing codebase with models and logic? I would very much like a way that doesnt include adding silverlight specific stuff to the logic? But it seems that's way easier.
Thanks in advance
EDIT:
The existing codebase simply contains a single model class. I want the model class to be viewed in a list in the WP7 app, and when the items get updated i want the UI to be updated aswell.
Upvotes: 0
Views: 119
Reputation: 33122
You'll need to implement the ObservableCollection and INotifyPropertyChanged pattern in your model.
You can wrap the existing model in a new class if you won't want to refactor your existing one but this typically results in pretty confusing code. I don't recommend it. For some simple stuff (consuming a small subset of the model) it works fine, but for larger models it becomes spaghetti very quickly.
Upvotes: 1
Reputation: 1068
Not knowing more about your code base, I'd say you should adapt MVVM (Model-View-ViewModel) architecture which blends nicely to situation you're describing.
You should write seperate view models for your models and those view models then implements INotifyPropertyChanged and all the other silverlight related stuff.
Here's a good article about implementing MVVM to WPF: WPF Apps With The Model-View-ViewModel Design Pattern. I know it's not for Silverlight but I believe same principles apply since Silverlight is just a subset from WPF.
Upvotes: 0