Disabling an individual Fab Tab Item

Oct 13, 2010 at 8:12 PM

I am currently using the fab tab control and really like it. I have a use case whereby I need to disable the close on the first fab tab and then let all the following fab tabs to close. How can I accomplish this?

I have been trying to style the tabitem's header but to no avail.

Thanks,

Farhan

Coordinator
Oct 13, 2010 at 8:24 PM

Farhan,

Just for clarification, are you looking to remove the close button altogether from the TabItem header of a given tab?  Or is it sufficient for the button to be there but not function when clicked?

Also, so I can gear my answer more towards your usage scenario, are you using FabTab's ItemsSource or just individual items?  If the latter, are you explicitly adding FabTabItems or are you simply adding your controls and letting the FabTabItems be generated for you behind the scenes?

Thanks,

Josh

Oct 13, 2010 at 10:54 PM

Thanks for the quick reply. I just found out that we could simply set the ShowCloseButton property to false for that particular tab item. I am using PRISM and ideally what I wanted to do was bind the itemsource to a collection. But the problem is that the views with in the tabs vary. What in your view should be the best way to deal with this scenario.

Also, the content tab shows all the windows with close buttons. But as I disabled the close button on the first tab item, I thought it would have been automatically reflected within the preview.

What could be the best approach to do this?

Thanks,

Farhan

Coordinator
Oct 14, 2010 at 2:26 AM

Hi Farhan, you are absolutely right, there was an inconsistency in the way the ContentTabView determined whether or not to show tab close buttons and the way the rest of the code worked.  ContentTabView just looked at the FabTabControl.ShowCloseButtons property to determine if it should display the close button.  I have changed it to look at the ShowCloseButton property on the FabTabItem itself.

If you pull the latest changeset from codeplex, I have checked in that change as well as an example of your scenario.  Now if you run the sample app and click on MVVM Window, you will see that Model View #1 does not have a close button but all the rest of them do (and this is also the case on the ContentTabView).  I accomplished this by having a binding in MVVMWindow.xaml in my FabTabItem style which bound the ShowCloseButton property to the AllowClose boolean property that I added in my ModelObject class which is found in the MVVMWindow.xaml codebehind. 

Incidentally, MVVMWindow is using the FabTabControl via ItemsSource binding so it should work fine for you with PRISM and MVVM.  Let me know if you have any other problems with it.

If you like the control, please give it a rating/review here on codeplex.

Thanks!

Josh

Coordinator
Oct 14, 2010 at 2:31 AM

Oh yeah, I also appreciate Tweets or blog postings about FabTab if you are so inclined ;)

Oct 14, 2010 at 5:09 PM

Thanks Josh,

 

That is prcisely what I was looking for. As my Fab Tab can host different types of tabs, having a generic observable collection seems to do the trick perfectly. The preview looks fantastic as well.

PS: While doing a mouse over on the tabs, sometimes the entire page is not shown within the preview. Could it be that the particular length of content is set.

I have left you a positive rating.

Thanks,

Farhan

Coordinator
Oct 14, 2010 at 5:26 PM

Farhan,

I have seen the behavior you are describing with the ToolTip snapshots before as well.  It boils down to the fact that the FabTab snapshots are somewhat at odds with the WPF Layout system.  Typically setting some kind of reasonable MinHeight and MinWidth values on the controls you are displaying within the FabTabItems helps those snapshots look better.  Without those values WPF will not take give much space to the controls, especially since they are actually hidden and you can see some goofy-looking, distorted snapshots.

If setting some reasonable minimums doesn't work, you may want to experiment with different types of panels, DockPanel, StackPanel, Canvas, Grid, etc and see if you get different results.  If you're not having any luck you can always zip up a sample solution and send it my way and I'll see if I can help.

Good luck (and thanks for the good review!)

Josh