MVVM

Feb 17, 2011 at 9:29 PM

Hi, I'm binding the Fabcontrol to an MVVM application (awesome control by the way) but having difficulties.

 

When I click a button the viewmodel adds another "Room" which is bound as a list to the Tabs. The first one works perfectly, however any attempt after that results in an error in ItemSourceStrategy.cs line 70 where The value "FabTab.ContentTabView" is not of type "KonnectChatter.Data.Room" and cannot be used in this generic collection.Parameter name: value

I do not start with any "Rooms" they are all created by clicking on the left side button (actually another DB list, but same effect)

any ideas for a workaround?

 

V

Coordinator
Feb 17, 2011 at 10:12 PM

Yeah, that makes perfect sense.  Presumably you have a property of type ObservableCollection<Room> that you are binding the ItemsSource of your FabTabControl to I would bet.  Basically you've got 3 ways to workaround this (I think):

1.  Set ShowContentTab="False" on your FabTabControl.  This will turn off the ContentTab functionality and therefore you will only have Rooms in your ItemsSource (behind the scenes FabTab tries to add a ContentTabView to your ItemsSource whenever there is more than 1 tab in the control)

2. Expose the property on your viewmodel as ObservableCollection<object> or ObservableCollection<DependencyProperty>---any type that your Rooms and FabTab's ContentTab view actually both subclass. This is a little ugly, but requires no FabTab source to be changed.

3. Since FabTab is open source, feel free to use a "one off" version of it--perhaps add an interface to FabTab's source, call it IView or something, them make your Rooms also implement that interface--then on your ViewModel expose an ObservableCollection<IView> or something like that. 

Don't forget, be sure to grab the latest changeset of FabTab, not the latest release if you want it to work (somewhat) well with the MVVM pattern.

Let me know what you end up doing.

Josh

Feb 18, 2011 at 2:09 AM

Ok so ShowContentTab=false fixed the problem immediately... But I really want to use the content tab and preview panes over tooltip images functionality.

So I complete option 2, and set my ContentTemplate to a different View (a usercontrol). It shows perfectly, but now in the combobox dropdown and the "preview" images it shows KonnectChatter.Data.Room instead of a preview of my view? Any ideas how to fix the combo box and preview or both?

Either way control still very awesome :)

V

Coordinator
Feb 18, 2011 at 12:17 PM

Versile,

So the reason you're seeing KonnectChatter.Data.Room is that you changed your ContentTemplate I am guessing.  I didn't quite follow why you needed to do that, could you explain why and maybe show me your XAML?  So at this point what is the type you are exposing via your ViewModel property for you ItemsSource?

Feb 21, 2011 at 2:16 PM

The tabItems are "Rooms" bound to my chat application in each Tab. So the "TabContent" is a custom UserControl linked to the Room the tab is bound to?

Coordinator
Feb 21, 2011 at 7:41 PM

Can you show me the xaml for your Window or UserControl in which you declare your FabTabControl?