TabControl WPF header
am 19.12.2007 11:51:08 von Vivien ParlatHi,
I'm quite puzzled with new TabControl in WPF. My basic need is to
display all tab headers in one row, each of them having a length
proportional to automatic length, or equal repartition.
I found how to do it with other TabControls (in Winforms...) but
interfaces changed when going to WPF.
My current algorithm is the following (if tbc is the TabControl):
1) store tbc.ActualWidth (because Width returns me NaN)
2) (optional, I tried to substract tbc.BorderThickness.Left and
tbc.BorderThickness.Right).
3) compute the sum of all tabs' ActualWidth
4) compute the ratio between available width and width taken by tabs
(step1 / step 3)
5) multiply all tab header widths by this ratio, and add them,
limiting last value not to exceed tbc.ActualWidth
I also tried by setting each tab width to (tbc.ActualWidth / tab
count).
The point is that, many times my tabs are laid out into 2 rows, or too
many pixels remain at the end.
Is there an anomaly in my approach, or a simpler way to achieve this
goal ?
Thank you in advance for any answer.