我可以将数据导入到我的TabControl中,但是标题周围有框架,我无法从标签到标签.
我在TabControl上使用XAML绑定语法做错了什么?
XAML:
代码背后:
public partial class Window1 : Window { public Window1() { InitializeComponent(); //create all Listcustomers = new List (); customers.Add(new Customer { FirstName = "Jim", LastName = "Smith", NumberOfContracts = 23 }); customers.Add(new Customer { FirstName = "Jane", LastName = "Smith", NumberOfContracts = 23 }); customers.Add(new Customer { FirstName = "John", LastName = "Tester", NumberOfContracts = 23 }); //show TheListBox.ItemsSource = customers; } } public class Customer { public string FirstName { get; set; } public string LastName { get; set; } public int NumberOfContracts { get; set; } }
小智.. 50
这就是我要做的
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { //create all var customers = new List{ new Customer {FirstName = "Jim", LastName = "Smith", NumberOfContracts = 23}, new Customer {FirstName = "Jane", LastName = "Smith", NumberOfContracts = 23}, new Customer {FirstName = "John", LastName = "Tester", NumberOfContracts = 23}}; //show TheTabControl.ItemsSource = customers; TheTabControl.SelectedIndex = 0; } public class Customer { public string FirstName { get; set; } public string LastName { get; set; } public int NumberOfContracts { get; set; } }
而在XAML方面
This is
啊!,`ContentTemplate`.谢谢! (6认同)
Joachim Kers.. 7
只需将List作为ItemsSource绑定到TabControl,例如
这将为您提供客户中每个对象的选项卡.
这就是我要做的
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { //create all var customers = new List{ new Customer {FirstName = "Jim", LastName = "Smith", NumberOfContracts = 23}, new Customer {FirstName = "Jane", LastName = "Smith", NumberOfContracts = 23}, new Customer {FirstName = "John", LastName = "Tester", NumberOfContracts = 23}}; //show TheTabControl.ItemsSource = customers; TheTabControl.SelectedIndex = 0; } public class Customer { public string FirstName { get; set; } public string LastName { get; set; } public int NumberOfContracts { get; set; } }
而在XAML方面
This is
只需将List作为ItemsSource绑定到TabControl,例如
这将为您提供客户中每个对象的选项卡.
你的答案可以在这里找到.
http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=31821
注意他如何设置ContentTemplate以及ItemTemplate ...你几乎拥有它!