user3345626
user3345626

Reputation: 243

WPF tab headers rearrange on window resize

I have a WPF application with 6 tab headers. They are arranged horizontally at the top of the application such that they span the full width of the window-- that is, when I drag the window to resize it, the tabItems stretch equally along with the window. The problem is that as I drag the window around, every 8-20 pixels or so they rearrange themselves for 1 or 2 pixels. In other words, I want them to look like

| Tab1 | Tab2 | Tab3 | Tab4 | Tab5 | Tab6 |

Say, for example, that the window is 300 pixels wide. The tabs continue to have the above arrangement when the window is 301-308 pixels wide, but at 309 and 310 pixels width, they look like this:

|    |Tab4|     |Tab5|     |Tab6|   |
|    |Tab1|     |Tab2|     |Tab3|   |

And finally, when the window is at 311 pixels wide, the tabs go back to their original arrangement. Has anyone ever seen this problem before? Where could it be coming from?

Upvotes: 0

Views: 484

Answers (1)

Giangregorio
Giangregorio

Reputation: 1510

The predefined style for TabControl use a TabPanel to display the tab headers (ref: https://msdn.microsoft.com/it-it/library/ms754137(v=vs.100).aspx).

A TabPanel can display headers in multiple rows if there is less width than needed.

You can change the style of your TabControl and substitute the TabPanel with another container according to your needs (for example a StackPanel with Orientation Horizontal).

Upvotes: 2

Related Questions