C# Class Com.Aote.Attachs.TabControlAttach

给TabControl附加属性,以便其可以绑定到数据源。原来的TabControl不支持绑定到数据源。
Datei anzeigen Open project: DuBin1988/restv2

Public Properties

Property Type Description
ContentTempalteProperty System.Windows.DependencyProperty
HeaderTemplateProperty System.Windows.DependencyProperty
ItemsSourceProperty System.Windows.DependencyProperty

Public Methods

Method Description
GetContentTempalte ( DependencyObject d ) : System.Windows.DataTemplate
GetHeaderTemplate ( DependencyObject d ) : System.Windows.DataTemplate
GetItemsSource ( DependencyObject d ) : IList
SetContentTempalte ( DependencyObject d, System.Windows.DataTemplate value ) : void
SetHeaderTemplate ( DependencyObject d, System.Windows.DataTemplate value ) : void
SetItemsSource ( DependencyObject d, IList value ) : void

Private Methods

Method Description
AddItems ( System.Windows.Controls.TabControl source, IEnumerable items ) : void

根据给定的列表数据,往TabControl中添加项目

DeleteItems ( System.Windows.Controls.TabControl tab, int index ) : void

根据给定的列表数据,从TabControl的Items中删除数据

OnContentTempalteChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

内容模板发生变化是,把所有已有项的内容模板换成新模板

OnHeaderTemplateChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

当头模板改变时,先将TabControl中已有项的头模板换掉

OnItemsSourceChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

当源发生改变时,获得源中的数据,产生TabItem,设置TabItem的DataContent为源中的数据。 TabItem的Header为Header模板转换结果,TabItem的Content为内容模板转换结果。 要注意的是,源是一个集合,所以必须监听集合中数据的变化,而不能只看集合本身。

Method Details

GetContentTempalte() public static method

public static GetContentTempalte ( DependencyObject d ) : System.Windows.DataTemplate
d System.Windows.DependencyObject
return System.Windows.DataTemplate

GetHeaderTemplate() public static method

public static GetHeaderTemplate ( DependencyObject d ) : System.Windows.DataTemplate
d System.Windows.DependencyObject
return System.Windows.DataTemplate

GetItemsSource() public static method

public static GetItemsSource ( DependencyObject d ) : IList
d System.Windows.DependencyObject
return IList

SetContentTempalte() public static method

public static SetContentTempalte ( DependencyObject d, System.Windows.DataTemplate value ) : void
d System.Windows.DependencyObject
value System.Windows.DataTemplate
return void

SetHeaderTemplate() public static method

public static SetHeaderTemplate ( DependencyObject d, System.Windows.DataTemplate value ) : void
d System.Windows.DependencyObject
value System.Windows.DataTemplate
return void

SetItemsSource() public static method

public static SetItemsSource ( DependencyObject d, IList value ) : void
d System.Windows.DependencyObject
value IList
return void

Property Details

ContentTempalteProperty public_oe static_oe property

内容模板,用于确定显示内容。
public static DependencyProperty,System.Windows ContentTempalteProperty
return System.Windows.DependencyProperty

HeaderTemplateProperty public_oe static_oe property

头模板,TabControl的数据源将利用该模板显示TabControl的头
public static DependencyProperty,System.Windows HeaderTemplateProperty
return System.Windows.DependencyProperty

ItemsSourceProperty public_oe static_oe property

ItemsSource附加属性,附加该属性后,TabControl就可以支持数据源绑定了。
public static DependencyProperty,System.Windows ItemsSourceProperty
return System.Windows.DependencyProperty