Is my thinking about mvvm right? - mvvm

I'm having a little bit of a hard time getting into mvvm. I'm writing a simple app, Notebook. I have one viewmodel, it's name is actually ViewModel. It has an ObservableCollection of Notes inside and methods to save and load those from Isolated Storage. My only Model is Note.cs, it implements INotifyPropertyChanged and I'm of course RaisingPropertyChanged.
I've also got two view, both of them are user controls. One to display list of notes and one to edit the one chosen from the list.
My questions are:
Where do I create an instance of my vievmodel?
How should I implement going from the page with list of notes to the page with detailed view after choosing one Note to edit? At the
moment I'm saving the index of Note in App.xaml.cs, going to the next page and setting
the DetailedView DataContext to the right Note in OnNavigatedTo, but
I don't think it's actually the perfect solution.
Where should I save my Notes? I guess Application_Closing in App.xaml.cs is the right place to do it, but I'd have to have my viewmodel as a global object there, is this the right approach?
Additional question:
I have to add possibility to group notes. I guess that class Group with dictionary (GroupName, howManyNotes) is going to be allright since I don't have to be able to for example write all notes from selected group. Do you think there's a better approach I should think about?
Thanks for respones,
MichaƂ.

I would suggest you take a look at Calibrun.Micro which is a great framework for MVVM. You can get some sample from the CodePlex.
I have used that in a bunch of Project, and will give you flexibility in case if your project grows in size.
Google for Caliburn.Micro sample and you will find a number of sample for all technologies like WPF, Silverlight, Windows Store, Windows Mobile.
Caliburn.Micro CodePlex

Related

Share data between views (ViewPart) Equinox

got a little question here to Eclipse Plugins.
I have a java class which contains some data, e.g. a linkedlist and some other stuff.
I need this data in 2 views. In one view I want to display some of them, and the other view should show a list with the data. (this is my special case, but I ask the question generally).
So, how can I use this one class in both views? In "normal" java I'd would give a reference when I create the views, but as far as I know this is not possible in eclipse plugins.
My solution is, that the data-class is a singleton. But I don't like this solution, I think this only works in my case.
Hope you got the point :) Do anyone of you know a better solution?
(i'm new in eclipse plugins, there aren't good books or tutorials, aren't there?)
To answer the second question in your post... try this site out for basic tutorials about Eclipse plug-ins and RCP applications.
www.vogella.com/eclipse.html
This answer should help with the first question in your post.
In SWT, all views just show a presentation of the underlying business objects. So when you implement the list and the tree, they just need to have the identical object as input (e.g. when calling treeViewer.setInput(theSharedDataObject)).
Your data class doesn't need to be a singleton for that, you just have to point to the same instance of the data.

How can I use the Inversion of Control concept in Sitecore to get non-page items to display themselves?

I have a number of non-page content items that are used as "callouts" on the side of pages throughout my website that I am building in Sitecore. Ideally I would like to be able to define the presentation information for these callouts independently. Then when a CMS author selects callouts for a particular page in the site, they know how to display themselves. I read an excellent blog post about how to do this here: http://www.awareweb.com/AwareBlog/InversionControl2.aspx. I used the first method that he describes in the post.
However my implementation of that code doesn't completely work. It seems to get the correct rendering and it iterates properly through the selected non-page callout items. But when it displays them on the page it seems like the callout items are still using Sitecore.Context.Item as their source item and not the source item that was passed in to them via the strDataSource variable as seen in the example code.
Do I have to do anything special in the code behind for the sublayouts for the callouts to tell them not to use Sitecore.Context.Item and instead to use the source item that was passed in? Otherwise I can't figure out why it's not working. Any ideas?
Thanks,
Corey
Setting the DataSource in a sublayout doesn't explicitly set the Context.Item to a different value, it just sets a property in a sublayout that it can use itself.
Rather than write up the solution again, John West's blog already covers this subject here, so I'd recommend you read that - http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/How-to-Apply-Data-Sources-to-Sitecore-ASPNET-Presentation-Components.aspx
I would recommend using the SublayoutParameterHelper Shared Source library which provides a Helper and a base class to use with your sublayouts for accessing the Item represented by an ID set in the DataSource; John also cites this library in his blog post.

Using GWT MVP on a single screen application

I apologize in advance as this is one of those "how does this work" type questions. I am a newbie to GWT MVP and I am trying to create a project similar to this one here:
where basically I have a menu of widgets/components that I can drag and drop onto a panel and doing so changes the properties shown in the Property disclosurepanel.
I have been reading about the official GWT MVP framework and they its described it seems like it expects each application state to represented by a whole new page (a View with an associated Place).
I am confused as to how this would work this type of application. That is, an application that has 1 basic screen that never entirely changes (i.e. user never navigates to a whole new screen) with sections that need to communicate to each other (i.e. dropping a widget loads a different set of properties).
I am sure I am misunderstanding something about MVP so if someone can just offer some advice on how to wrap my brain around this that would be great.
It's not impossible to utilize the MVP paradigm with more than one on-screen regions.
You can read about a possible solution in this article. It's the last post of a four-part series. I suggest reading also the preceeding posts from the author with the same tags.

Simple Core Data Example App?

I am trying to learn about core data on the iPhone, and I am looking for a simple Core Data example app.
The problem is, all the example apps I've seen are either too simple (just one view and one data object), or so full of extra functions that it's hard to see what's relevant (Apple's example apps).
I'm looking for an example app with:
an ordinary cascading to-many relationship (e.g. Company > Departments > Employees)
a simple drill-down interface (e.g. click on a company to see list of departments; click on a department to see list of employees; click on an employee to see name and address)
simple editing (press plus for modal view to add company/department/employee)
... so I can learn the basics about passing contexts between views, NSFetchedResultsController etc.
Does anyone know of such a thing?
Thanks!
Try the example found here: Wiley Code Examples
Click on Chapter 18 - Downloads.
Hope this helps.
Let It Be Known
I would recommend Marcus Zarra's Core Data book and the examples therein. He takes one example app that starts off very simple and incrementally adds complexity.
RecipeCT is the project that I would suggest looking at first. Having the book would help you navigate from project to project as the basic Recipes app transforms.

iPhone example to go through

Can you provide me a basic iPhone example which has the following;
a. It is primarily a navigation-based app (Top-level view, Detail view, etc)
b. It also uses table (to present list of items, item details, add, edit, delete)
c. It uses Core Data for storing the list items
d. Optionally, it would be really great if it uses an API for retrieving some of the table data (otherwise user entered if API does not return).
While I do have individual examples for all these thing, I ma basically looking for an example which kind of combines all these things into a single app.
I have already gone through some of the IOS developer reference and hence would want other combined examples.
Any reference examples would be highly appreciated.
Thanks a lot.
Have you looked through the iOS Sample Code library? You'll find examples of all these. They have TopSongs (API, Navigation Views, Table Views, Core Data) and CoreDataBooks for Core Data.
If you create a project using the Navigation based template and select "Use Core Data" you will get the skeleton of exactly the type of app you want.
Examples covering all of those are on Apple's developer website, developer.apple.com.
I used this one is one, to learn this: http://icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/#create-db