code_junkie

How to automatically extend the tab control as items are added to it without creating a scroll bar?

Nov 11th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. ....
  2. foreach (string id in ids)
  3. {
  4. TabControl.Items.Add(CreateTabItem(id));
  5. }
  6.  
  7. private TabItem CreateTabItem(string name)
  8. {
  9. StackPanel txtBlock = new TextBlock();
  10. txtblock.Text = name;
  11. txtBlock.HorizontalAlignment = Horizontalalignment.Center;
  12. panel.Children.Add(txtBlock);
  13.  
  14. TabItem item = new TabItem();
  15. item.Header = panel;
  16.  
  17. <SomeControl> control = new <SomeControl>();
  18. item.Content = control;
  19. return item;
  20. }
  21.  
  22. MinWidth="100" MinHeight="300" TabStripPlacement="Left"
  23.  
  24. <ScrollViewer>
  25. <TabControl
  26. TabStripPlacement="Left"
  27. x:Name="Tab"
  28. >
  29. </TabControl>
  30. </ScrollViewer>
Add Comment
Please, Sign In to add comment