1

Closed

FabTabItem's dependency on FabTabControl should be broken.

description

When instantiating FabTabItems directly in code, they aren't populated with the FabTabControl. This leads to a NullReferenceException in FabTabItem when it's presenting itself. If you do a null check on line 38, it won't display the close boxes. I'm working around this by putting a method on FabTabControl called Populate(FabTabItem item), but it's hackish. The better way to do this is remove the FabTabControl property on FabTabItem and instead do the following:
 
1) Create an internal property on FabTabItem called CloseButtonVisibility, which is set by the FabTabControl when it receives the FabTabItem.
2) Create an internal event on FabTabItem called CloseButtonClicked, which the FabTabContainer will listen to, and in response call CloseTab(sender).
 
BTW, thanks very much for your updates earlier, they were really useful.

file attachments

Closed Oct 4, 2009 at 9:46 PM by adajos
This seems to be resolved.

comments

darthtrevino wrote Oct 1, 2009 at 11:03 PM

On #2, you can just have the TabControl listen to the TabClosing event, no need for a new one.

wrote Oct 2, 2009 at 2:33 PM

darthtrevino wrote Oct 2, 2009 at 4:48 PM

I resolved this for my project. The patch is attached.

wrote Oct 2, 2009 at 4:49 PM

adajos wrote Oct 2, 2009 at 6:12 PM

darthtrevino,

I completely agree with you on the dependency of FabTabItem on FabTabControl. To that end I've broken the dependency, although I did it slightly differently than you suggested, opting to use databinding to set the visibility of the close buttons on the FabTabItems. Also i revamped the Closing event stuff, you had some great points there. When I actually release I will now have to update the documentation on the Home page because we no longer have TabClosingRoutedEvents args with a cancel property--now we just use a RoutedEvent and subscribers can mark e.Handled = true if they dont' want the tab to close.

I didn't see your patch until I had committed my changes...hopefully they will work ok together. They are in the latest changeset.

Let me know.

darthtrevino wrote Oct 2, 2009 at 6:31 PM

yeah, that actually worked really well. Thanks adajos!

darthtrevino wrote Oct 2, 2009 at 6:50 PM

So the only thing I notice now is that I have to call OnApplyTemplate() whenever I'm adding a FabTabItem to the FabTabControl if I want the close button to show up.

adajos wrote Oct 2, 2009 at 7:47 PM

Are you doing it differently than I am in NoXamlWindow.xaml.cs? In there I'm dynamically adding tabs and the close buttons show up fine...I am doing it in the Loaded event handler for the window though---are you doing it sooner than that?

adajos wrote Oct 2, 2009 at 7:48 PM

BTW, thanks for A) expressing an interest in my control and B) having so many useful suggestions.

darthtrevino wrote Oct 2, 2009 at 8:27 PM

Hey adajos, it looks like I was just going crazy. Thanks for the great tab control!

wrote Oct 4, 2009 at 9:46 PM

wrote Feb 14, 2013 at 6:36 PM

wrote May 16, 2013 at 9:15 AM