Лучший отвечающий
добавить ScrollBar в пользовательский элемент управления при добавление его в TabControl

Вопрос
-
пишу приложение на WPF и захотелось мне создать вкладки с различными элементами управления для этого решил использовать TabControl и пользовательский элемент управления UserControl1 по размерам превышающий TabControl, т.е. отображается только часть моего элемента управления. Я хочу как нибудь всунуть туда прокрутку для просмотра остальной части UserControl1. вот только не знаю как ниже код как я его добавляю.
UserControl1 w = new UserControl1(); TabItem it = new TabItem(); it.Header = "newtab"; it.Content=w; tabControl1.Items.Add(it);
15 декабря 2010 г. 23:24
Ответы
-
UserControl1 userControl1 = new UserControl1(); ScrollViewer scrollViewer = new ScrollViewer(); scrollViewer.Content = userControl1; TabItem tabItem = new TabItem(); tabItem.Header = "newtab"; tabItem.Content = scrollViewer; tabControl1.Items.Add(tabItem);
- Помечено в качестве ответа Valmet 16 декабря 2010 г. 9:06
16 декабря 2010 г. 6:36
Все ответы
-
UserControl1 userControl1 = new UserControl1(); ScrollViewer scrollViewer = new ScrollViewer(); scrollViewer.Content = userControl1; TabItem tabItem = new TabItem(); tabItem.Header = "newtab"; tabItem.Content = scrollViewer; tabControl1.Items.Add(tabItem);
- Помечено в качестве ответа Valmet 16 декабря 2010 г. 9:06
16 декабря 2010 г. 6:36 -
да вроде работает еще вопросик, Какое свойство надо изменить что при изменение размера формы, размер ScrollViewer подстраивался под размер tabItem а не оставался таким же ?16 декабря 2010 г. 8:45
-
*DONT_KNOW*
у мня все норм растягивается)))<Window x:Class="tabscroll.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <TabControl Name="tabControl1"> </TabControl> </Grid> </Window> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace tabscroll { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); UserControl1 userControl1 = new UserControl1(); ScrollViewer scrollViewer = new ScrollViewer(); scrollViewer.Content = userControl1; TabItem tabItem = new TabItem(); tabItem.Header = "newtab"; tabItem.Content = scrollViewer; tabControl1.Items.Add(tabItem); } } }
16 декабря 2010 г. 8:58 -
да все норм под таб контролом был техт бох он растягивался а таб контрол нет я их перепутал16 декабря 2010 г. 9:06