GridViewColumn GridViewColumn GridViewColumn GridViewColumn Class

定義

表示顯示資料的資料行。Represents a column that displays data.

public ref class GridViewColumn : System::Windows::DependencyObject, System::ComponentModel::INotifyPropertyChanged
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
[System.Windows.Markup.ContentProperty("Header")]
[System.Windows.StyleTypedProperty(Property="HeaderContainerStyle", StyleTargetType=typeof(System.Windows.Controls.GridViewColumnHeader))]
public class GridViewColumn : System.Windows.DependencyObject, System.ComponentModel.INotifyPropertyChanged
type GridViewColumn = class
    inherit DependencyObject
    interface INotifyPropertyChanged
Public Class GridViewColumn
Inherits DependencyObject
Implements INotifyPropertyChanged
繼承
屬性
實作

範例

下列範例顯示如何定義GridViewColumnGridView物件。The following example shows how to define GridViewColumn objects for a GridView.


<ListView ItemsSource="{Binding Source={StaticResource EmployeeData}, 
                                        XPath=Employee}">
  <ListView.View>       
    <GridView>
      <GridViewColumn Header="First Name"
               DisplayMemberBinding="{Binding XPath=FirstName}" />
      <GridViewColumn Header="Last Name"  
               CellTemplate="{StaticResource LastNameCellTemplate}"/>
      <GridViewColumn Header="Favorite City" 
               CellTemplateSelector="{DynamicResource 
                                      FavoriteCityTemplateSelector}"/>
    </GridView>
  </ListView.View>    
</ListView>

備註

GridView View 模式會使用來顯示資料行。 GridViewColumnA GridViewColumn is used by the GridView view mode to display a column of data. 執行 view 模式的ListViewGridView提供資料行的資料。The ListView that implements the GridView view mode provides the data for the column. 您可以使用資料系結來指定的資料GridViewColumnYou use data binding to specify the data for the GridViewColumn.

您可以使用DisplayMemberBinding來定義要在資料行中顯示的資料。You can use the DisplayMemberBinding to define the data to display in a column. 您也可以將資料定義為DataTemplate CellTemplate屬性所指定之的一部分。You can also define the data as part of a DataTemplate that is specified by the CellTemplate property. 如果不同的CellTemplateSelector資料格DataTemplate具有不同的物件, 屬性可以DataTemplateSelector指定。If different cells have different DataTemplate objects, the CellTemplateSelector property can specify a DataTemplateSelector. 下列清單顯示這裡所述的屬性, 順序從最高到最低的優先順序:The following list shows the properties mentioned here, in their order of precedence from highest to lowest:

GridViewColumn類別也包含屬性, 可讓您用來定義和自訂資料行的資料行標頭。The GridViewColumn class also contains properties that you can use to define and customize the column header for the column. Header屬性可以定義資料行標頭的內容。The Header property can define the content of the column header. 其他屬性 (例如HeaderTemplateHeaderContainerStyle ) 也可以指定資料行標頭的內容和樣式。Other properties such as HeaderTemplate and HeaderContainerStyle can also specify content and style for the column header. 其中一些屬性也可以在其他類別 (例如GridViewColumnHeader類別) 上找到。Some of these properties are also found on other classes such as the GridViewColumnHeader class. 如需用來定義資料行標頭樣式和範本之屬性的詳細資訊, 以及這些屬性的優先順序相關資訊, 請參閱GridView 資料行標頭樣式和範本總覽For more information about the properties that are used to define styles and templates for column headers, and for information about the order of precedence for these properties, see GridView Column Header Styles and Templates Overview.

GridViewColumn 類別會實作 INotifyPropertyChanged 介面。The GridViewColumn class implements the INotifyPropertyChanged interface. 這個介面可讓您訂閱屬性值發生變更時所發生的事件, 例如ActualWidth屬性值。This interface provides the ability to subscribe to the events that occur when a change occurs to a property value, such as the ActualWidth property value.

建構函式

GridViewColumn() GridViewColumn() GridViewColumn() GridViewColumn()

初始化 GridViewColumn 類別的新執行個體。Initializes a new instance of the GridViewColumn class.

欄位

CellTemplateProperty CellTemplateProperty CellTemplateProperty CellTemplateProperty

識別 CellTemplate 相依性屬性。Identifies the CellTemplate dependency property.

CellTemplateSelectorProperty CellTemplateSelectorProperty CellTemplateSelectorProperty CellTemplateSelectorProperty

識別 CellTemplateSelector 相依性屬性。Identifies the CellTemplateSelector dependency property.

HeaderContainerStyleProperty HeaderContainerStyleProperty HeaderContainerStyleProperty HeaderContainerStyleProperty

識別 HeaderContainerStyle 相依性屬性。Identifies the HeaderContainerStyle dependency property.

HeaderProperty HeaderProperty HeaderProperty HeaderProperty

識別 Header 相依性屬性。Identifies the Header dependency property.

HeaderStringFormatProperty HeaderStringFormatProperty HeaderStringFormatProperty HeaderStringFormatProperty

識別 HeaderStringFormat 相依性屬性。Identifies the HeaderStringFormat dependency property.

HeaderTemplateProperty HeaderTemplateProperty HeaderTemplateProperty HeaderTemplateProperty

識別 HeaderTemplate 相依性屬性。Identifies the HeaderTemplate dependency property.

HeaderTemplateSelectorProperty HeaderTemplateSelectorProperty HeaderTemplateSelectorProperty HeaderTemplateSelectorProperty

識別 HeaderTemplateSelector 相依性屬性。Identifies the HeaderTemplateSelector dependency property.

WidthProperty WidthProperty WidthProperty WidthProperty

識別 Width 相依性屬性。Identifies the Width dependency property.

屬性

ActualWidth ActualWidth ActualWidth ActualWidth

取得 GridViewColumn 的實際寬度。Gets the actual width of a GridViewColumn.

CellTemplate CellTemplate CellTemplate CellTemplate

取得或設定用來顯示資料行儲存格內容的範本。Gets or sets the template to use to display the contents of a column cell.

CellTemplateSelector CellTemplateSelector CellTemplateSelector CellTemplateSelector

取得或設定 DataTemplateSelector,它會決定要用於顯示資料行中儲存格的範本。Gets or sets a DataTemplateSelector that determines the template to use to display cells in a column.

DependencyObjectType DependencyObjectType DependencyObjectType DependencyObjectType

取得包裝此執行個體之 CLRCLR 型別的 DependencyObjectTypeGets the DependencyObjectType that wraps the CLRCLR type of this instance.

(Inherited from DependencyObject)
Dispatcher Dispatcher Dispatcher Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
DisplayMemberBinding DisplayMemberBinding DisplayMemberBinding DisplayMemberBinding

取得或設定要繫結至此資料行的項目。Gets or sets the data item to bind to for this column.

Header Header Header Header

取得或設定 GridViewColumn 行首的內容。Gets or sets the content of the header of a GridViewColumn.

HeaderContainerStyle HeaderContainerStyle HeaderContainerStyle HeaderContainerStyle

取得或設定要用於 GridViewColumn 標頭的樣式。Gets or sets the style to use for the header of the GridViewColumn.

HeaderStringFormat HeaderStringFormat HeaderStringFormat HeaderStringFormat

取得或設定複合字串,這個字串會指定在 Header 屬性顯示為字串的情況下,如何格式化這個屬性。Gets or sets a composite string that specifies how to format the Header property if it is displayed as a string.

HeaderTemplate HeaderTemplate HeaderTemplate HeaderTemplate

取得或設定用來顯示資料行標頭內容的範本。Gets or sets the template to use to display the content of the column header.

HeaderTemplateSelector HeaderTemplateSelector HeaderTemplateSelector HeaderTemplateSelector

取得或設定 DataTemplateSelector,其中提供的邏輯可選擇要用來顯示資料行行首的範本。Gets or sets the DataTemplateSelector that provides logic to select the template to use to display the column header.

IsSealed IsSealed IsSealed IsSealed

取得值,這個值表示此執行個體目前是否已密封 (唯讀)。Gets a value that indicates whether this instance is currently sealed (read-only).

(Inherited from DependencyObject)
Width Width Width Width

取得或設定資料行的寬度。Gets or sets the width of the column.

方法

CheckAccess() CheckAccess() CheckAccess() CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

清除屬性的區域數值。Clears the local value of a property. 要清除的屬性是由 DependencyProperty 識別項所指定。The property to be cleared is specified by a DependencyProperty identifier.

(Inherited from DependencyObject)
ClearValue(DependencyPropertyKey) ClearValue(DependencyPropertyKey) ClearValue(DependencyPropertyKey) ClearValue(DependencyPropertyKey)

清除唯讀屬性的區域數值。Clears the local value of a read-only property. 要清除的屬性是由 DependencyPropertyKey 所指定。The property to be cleared is specified by a DependencyPropertyKey.

(Inherited from DependencyObject)
CoerceValue(DependencyProperty) CoerceValue(DependencyProperty) CoerceValue(DependencyProperty) CoerceValue(DependencyProperty)

強制轉型所指定相依性屬性的值。Coerces the value of the specified dependency property. 叫用存在於呼叫 CoerceValueCallback 上相依性屬性之屬性中繼資料內所指定的任何 DependencyObject 函式,就可以達到這一點。This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.

(Inherited from DependencyObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷提供的 DependencyObject 和目前的 DependencyObject 是否相等。Determines whether a provided DependencyObject is equivalent to the current DependencyObject.

(Inherited from DependencyObject)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

取得這個 DependencyObject 的雜湊程式碼。Gets a hash code for this DependencyObject.

(Inherited from DependencyObject)
GetLocalValueEnumerator() GetLocalValueEnumerator() GetLocalValueEnumerator() GetLocalValueEnumerator()

建立特定的列舉值,以判斷哪些相依性屬性在此 DependencyObject 上具有本機設定的值。Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.

(Inherited from DependencyObject)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

(Inherited from DependencyObject)
InvalidateProperty(DependencyProperty) InvalidateProperty(DependencyProperty) InvalidateProperty(DependencyProperty) InvalidateProperty(DependencyProperty)

重新評估指定之相依性屬性的有效值。Re-evaluates the effective value for the specified dependency property

(Inherited from DependencyObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
OnHeaderStringFormatChanged(String, String) OnHeaderStringFormatChanged(String, String) OnHeaderStringFormatChanged(String, String) OnHeaderStringFormatChanged(String, String)

發生於 HeaderStringFormat 屬性變更時。Occurs when the HeaderStringFormat property changes.

OnPropertyChanged(DependencyPropertyChangedEventArgs) OnPropertyChanged(DependencyPropertyChangedEventArgs) OnPropertyChanged(DependencyPropertyChangedEventArgs) OnPropertyChanged(DependencyPropertyChangedEventArgs)

每當這個 DependencyObject 上任何相依性屬性的有效值已更新時叫用。Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. 已變更的特定相依性屬性會在事件資料中報告。The specific dependency property that changed is reported in the event data.

(Inherited from DependencyObject)
OnPropertyChanged(PropertyChangedEventArgs) OnPropertyChanged(PropertyChangedEventArgs) OnPropertyChanged(PropertyChangedEventArgs) OnPropertyChanged(PropertyChangedEventArgs)

引發 INotifyPropertyChanged.PropertyChanged 事件。Raises the INotifyPropertyChanged.PropertyChanged event.

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

傳回相依性屬性的區域值 (如果存在)。Returns the local value of a dependency property, if it exists.

(Inherited from DependencyObject)
SetCurrentValue(DependencyProperty, Object) SetCurrentValue(DependencyProperty, Object) SetCurrentValue(DependencyProperty, Object) SetCurrentValue(DependencyProperty, Object)

設定相依性屬性的值,而不需要變更其值來源。Sets the value of a dependency property without changing its value source.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object) SetValue(DependencyProperty, Object) SetValue(DependencyProperty, Object) SetValue(DependencyProperty, Object)

設定相依性屬性的區域值 (由相依性屬性的識別碼所指定)。Sets the local value of a dependency property, specified by its dependency property identifier.

(Inherited from DependencyObject)
SetValue(DependencyPropertyKey, Object) SetValue(DependencyPropertyKey, Object) SetValue(DependencyPropertyKey, Object) SetValue(DependencyPropertyKey, Object)

設定唯讀相依性屬性的區域數值 (由相依性屬性的 DependencyPropertyKey 識別項所指定)。Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.

(Inherited from DependencyObject)
ShouldSerializeProperty(DependencyProperty) ShouldSerializeProperty(DependencyProperty) ShouldSerializeProperty(DependencyProperty) ShouldSerializeProperty(DependencyProperty)

傳回值,這個值表示序列化程序是否應該序列化所提供相依性屬性的值。Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.

(Inherited from DependencyObject)
ToString() ToString() ToString() ToString()

建立 GridViewColumn 的字串表示。Creates a string representation of the GridViewColumn.

VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

請強制執行可以存取這個 DispatcherObject 的呼叫執行緒。Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)

明確介面實作

INotifyPropertyChanged.PropertyChanged INotifyPropertyChanged.PropertyChanged INotifyPropertyChanged.PropertyChanged INotifyPropertyChanged.PropertyChanged

發生於任何 GridViewColumn 屬性的值變更時。Occurs when the value of any GridViewColumn property changes.

適用於

另請參閱