I'm working my way through the MVVM video series on a SL4 solution. In my little project I have not yet adopted a navigation framework (like Bxf). Right now I'm just trying to bind a businesslist to a listbox. I'm using the drag and drop of the data sources like in the video. VS created 2 collectionviewsource resources. (ViewModelViewSource and ViewModelModelViewSource) The ViewModelModelViewSource binds to the Model property on ViewModelViewSource. I just can't figure how to get bind an instance of my ViewModel to ViewModelViewSource.
I tried setting the ViewModelViewSource.Source to an instance of my view model but it doesn't work I get the error: Unsupported type of source for a collection view.
I tried setting the ViewModelViewSource.Source to the model property of my view model. This does not throw an error but my listbox doesn't populate either.
I've missed a step here. Any help would be appreciated.
You would normally do this in the Load method of your container object (Control, Page, Window, etc.)
Something similar to this.
CollectionViewSource cvs =
(CollectionViewSource)this.Resources["siteInfoListViewSource"];
SiteInfoList sl = SiteInfoList.GetSiteInfoListFromCorp01();
cvs.Source = sl;
One other note...
You would probably want to encapsulate this with the following if statement, so it doesn't run during design time and give you headaches.
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) {
Should it be binding to my ViewModel<T> class?
Copyright (c) Marimer LLC