FabTab with Caliburn Micro

Sep 29, 2010 at 3:12 PM

Moving the discussion of FabTab with Caliburn.Micro to here instead of the Caliburn.Micro forums.  Original discussion can be found here: http://caliburnmicro.codeplex.com/Thread/View.aspx?ThreadId=228941.

Coordinator
Sep 29, 2010 at 3:14 PM

adfreeman,

Any chance I can get you to zip a sample solution that in a simplified way demonstrates the issue you are seeing?

Thanks,

Josh

Sep 29, 2010 at 3:29 PM

I will see If I can put one together.

Sep 29, 2010 at 7:19 PM

The initial problem was with the template.  However; there is still an additional problem with the application.  If you add more than one tabpage you get the following error:

The value "FabTab.ContentTabView" is not of type "Caliburn.Micro.IScreen" and cannot be used in this generic collection. 

You can get the sample project from here: http://dl.dropbox.com/u/12424553/FabTabTest.zip

 

Coordinator
Sep 29, 2010 at 7:31 PM

Awesome, I'm looking at it now.

Coordinator
Sep 29, 2010 at 7:42 PM

Hey adfreeman,

Not sure exactly what particular FabTab functionality you are looking for in your app, but if you set ShowContentsTab="False" on the FabTabControl you declare in your ShellView.xaml then it all works beautifully.

Of course you won't have the ContentTabView then.  The problem I am seeing makes perfect sense--you're correctly trying to bind the ItemsSource of FabTab to a BindableCollection<IScreen> off of the Conductor, but then when I try to "trick" FabTab into adding the ContentTabView in behind the scenes we get that Exception because ContentTabView doesn't implement IScreen and can't be added to the Collection.

There's a number of ways to solve this.  One would be for me to somehow allow the FabTabConsumer to create their own sort of ContentTabView which could then be made to implement whatever interfaces are necessary.  I suspect that would be fairly involved. You'll notice that anywhere in the FabTab Sample project where I use the ItemsSource to populate the control I bind to ObservableCollection<object>;  That allows me to add in ContentTabView behind the scenes and have it work. But that's not a great solution is it?  let me think about that

Another would be for you to modify the FabTab source to make ContentTabView implement IScreen...that's the beauty of open source, you have the ability to create your own version of FabTab which references Caliburn Micro and does what you need.

I'll keep you posted on my thoughts about this as  I poke around.  Let me know if you have any ideas or whether you even care about the ContentTab functionality.

Thanks,

Josh

Coordinator
Sep 29, 2010 at 7:53 PM

Another thing which I tried was changing your ShellViewModel to subclass Conductor<DependencyObject> and then change your TabPageViewModel to subclass DependencyObject also.  Since ContentTabView also descends from DO, we get past our typing issues.

However, when I do that and click on the Content Tab instead of showing the ContentTabView as I would expect, I see "FabTab.ContentTabView not found" because Caliburn is, I think trying to use its conventions to find a view that matches what it thinks is a ViewModel in ContentTabView. Hmmm....I wonder if Caliburn Micro has a way to ignore it's convention if it fails to resolve a view and just attempt to render what it's got in its BindableCollection<DependencyObject> Items collection...?

Sep 29, 2010 at 8:21 PM

Thanks for the feedback.  I can do without the ContentTabView initially but would like to have it at some point.  I know CAlibrun.Micro supports setting ViewLookup conventions. I will need to look into it to see how it is done.  That may be the way to go.

Coordinator
Sep 29, 2010 at 8:34 PM

I will keep looking into this and keep you posted.  If you find your own solution for this, please post it here.

Thanks,

Josh