Tabs count

Apr 15, 2010 at 12:48 PM
Edited Apr 15, 2010 at 1:04 PM

Hi !

When doing some experimentation with Fabtab, I have seen something that, I thing, can cause problems.
The FabTab control can give us the number of tabs that are opened with the method :

tabControl.Items.Count

 

That's a very useful thing but I think that there is a problem in the count. In fact, you are counting the "Content Tab" as a "normal" tab. This can be good but also a problem.
For example, if I want to "link" each view on a  tab with a element (basically an object binded to the IU elements) of an arraylist  , I will have a problem after the second tab is adding because the Content Tab will become the third tab.

Do you see what I mean ?
I think that it can be good to let the choice to count or not the Content Tab in the overall tab count.

Coordinator
Apr 16, 2010 at 1:34 AM

Tuttu,

Hmm...I will have to give this some thought.  I see your point.  It'll be tricky though because the Count property is on the ItemsCollection which is a property on ItemsControl.  I could subclass CollectionView rather than using ItemsCollection so I could give its Count property the kind of intelligence you are describing.  But the problem is that I've tried to just extend what the WPF TabControl gives us as much as possible and that would be a significant departure from that.

What if I just created another property on FabTabControl called ItemsCountWithoutContentTab or something?

Thoughts?

Josh

Apr 16, 2010 at 8:29 AM

Hi Josh !

 

Yes, I think that a simple property called ItemsCountWithoutContentTab would be great. But how to implement it ?
Just substract one to the total of tabs when this total is equal or superior to three ? Is that enought ?

 

Regards,
Tuttu

Coordinator
Apr 17, 2010 at 12:48 AM

Tuttu,

I'm thinking something like this should be added to FabTabControl:

public int ItemsCountWithoutContentTab

{

get

{

if(!ShowContentsTab)

return this.Items.Count;

if(this.Items.Count >= 3)

return this.Items.Count - 1;

return this.Items.Count;

}

}

I haven't gotten a chance to thoroughly test it yet, but I think that should do the trick.  Will that meet your needs?

Josh

 
Apr 17, 2010 at 7:20 AM

Thank you for this piece of code. I will test it when I will have the time (no later than next monday) and I will keep you inform about the result. :)

Apr 19, 2010 at 12:33 PM

Hi Josh !

I have tested your code and it seems to work very well. I have added it to the TabControl.cs and I have modified TabItemsWIndows.xaml.cs to use the new property.
Everything is good. I think that you can add this property to your next release.


Thank you again for this code.

Regards, Tuttu

Coordinator
Apr 19, 2010 at 11:30 PM

Tuttu,

Thanks for the update.  Look for that code to be in the next release.  At this point, I'm not sure exactly when that will be.  But I will put it into a changeset in a week or so.

Josh