GridViewColumn 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表一個顯示資料的欄位。
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
[<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))>]
type GridViewColumn = class
inherit DependencyObject
interface INotifyPropertyChanged
Public Class GridViewColumn
Inherits DependencyObject
Implements INotifyPropertyChanged
- 繼承
- 屬性
- 實作
範例
以下範例展示了如何定義 GridViewColumn 物件。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>
備註
GridViewColumn A 是檢視模式用GridView來顯示資料欄位的。 實作GridView檢視模式的 ListView 該欄位提供資料。 你使用資料綁定來指定 GridViewColumn.
你可以用 來 DisplayMemberBinding 定義要顯示在欄位中的資料。 你也可以將資料定義為屬性指定CellTemplate的一部分DataTemplate。 若不同儲存格有不同DataTemplate物件,該CellTemplateSelector性質可指定 。DataTemplateSelector 以下列表依優先順序從高到低排列,列出此處提及的屬性:
這個 GridViewColumn 類別也包含屬性,可以用來定義和自訂該欄位的欄位標頭。 該 Header 屬性可以定義欄位標頭的內容。 其他屬性 HeaderTemplate 如 和 HeaderContainerStyle 也能指定欄位標頭的內容與樣式。 這些性質中有些也存在於其他類別,例如該 GridViewColumnHeader 類別。 欲了解更多用於定義欄位標頭樣式與範本的屬性,以及這些屬性的優先順序,請參閱 GridView 欄位標頭樣式與範本概覽。
GridViewColumn 類別會實作 INotifyPropertyChanged 介面。 此介面提供訂閱屬性值變更事件的能力,例如屬性值。ActualWidth
建構函式
| 名稱 | Description |
|---|---|
| GridViewColumn() |
初始化 GridViewColumn 類別的新執行個體。 |
欄位
| 名稱 | Description |
|---|---|
| CellTemplateProperty |
識別 CellTemplate 依賴性質。 |
| CellTemplateSelectorProperty |
識別 CellTemplateSelector 依賴性質。 |
| HeaderContainerStyleProperty |
識別 HeaderContainerStyle 依賴性質。 |
| HeaderProperty |
識別 Header 依賴性質。 |
| HeaderStringFormatProperty |
識別 HeaderStringFormat 依賴性質。 |
| HeaderTemplateProperty |
識別 HeaderTemplate 依賴性質。 |
| HeaderTemplateSelectorProperty |
識別 HeaderTemplateSelector 依賴性質。 |
| WidthProperty |
識別 Width 依賴性質。 |
屬性
| 名稱 | Description |
|---|---|
| ActualWidth |
得到 的實際寬度是 GridViewColumn。 |
| CellTemplate |
取得或設定範本以顯示欄位儲存格的內容。 |
| CellTemplateSelector |
取得或設定 , DataTemplateSelector 決定用來顯示欄位儲存格的範本。 |
| DependencyObjectType |
會取得 DependencyObjectType 包裹此實例 CLR 類型的 。 (繼承來源 DependencyObject) |
| Dispatcher |
了解 Dispatcher 這與此 DispatcherObject 有關。 (繼承來源 DispatcherObject) |
| DisplayMemberBinding |
取得或設定此欄位要綁定的資料項目。 |
| Header |
取得或設定 GridViewColumn。 |
| HeaderContainerStyle |
取得或設定 . 的標頭 GridViewColumn所用的樣式。 |
| HeaderStringFormat |
取得或設定一個複合字串,指定若以字串形式顯示的 Header 屬性,該格式化該方式。 |
| HeaderTemplate |
取得或設定範本以顯示欄位標頭的內容。 |
| HeaderTemplateSelector |
取得或設定 DataTemplateSelector ,提供選擇用來顯示欄位標頭的範本的邏輯。 |
| IsSealed |
會獲得一個值,表示該實例目前是否封存(唯讀)。 (繼承來源 DependencyObject) |
| Width |
取得或設定欄位的寬度。 |
方法
明確介面實作
| 名稱 | Description |
|---|---|
| INotifyPropertyChanged.PropertyChanged |
當任何 GridViewColumn 房產的價值變動時,就會發生這種情況。 |