Grid 類別

定義

定義彈性的格線區域,由欄與列組成。 Grid 的子元素會根據其數據列/數據行指派來測量和排列, (使用 Grid.RowGrid.Column 附加屬性) 和其他邏輯來設定。

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Grid : Panel
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class Grid : Panel
Public Class Grid
Inherits Panel
<Grid ...>
  oneOrMoreUIElements
</Grid>
-or-
<Grid .../>
繼承
衍生
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

提示

如需詳細資訊、設計指引和程式碼範例,請參閱 版面配置面板

如果您已安裝 WinUI 2 資源庫 應用程式,請按下這裡 開啟應用程式並查看方格運作情形

這個 XAML 範例示範如何使用 Grid 設計版面配置。

<Grid x:Name="LayoutRoot" Background="#555555" Width="400" Height="300">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="250" />
        <ColumnDefinition Width="150" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="2*" />
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" 
               Margin="10" FontWeight="Bold" 
               Text="Contoso Corporation" HorizontalAlignment="Center" VerticalAlignment="Center" />
    <Grid x:Name="FormLayoutGrid" Grid.Row="1" Grid.Column="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Grid.Column="0" Text="First Name" Margin="10" 
                   HorizontalAlignment="Left" VerticalAlignment="Center" />
        <TextBox Grid.Row="0" Grid.Column="1" Margin="10" />
        <TextBlock Grid.Row="1" Grid.Column="0" Text="Last Name" Margin="10" 
                   HorizontalAlignment="Left" VerticalAlignment="Center" />
        <TextBox Grid.Row="1" Grid.Column="1" Margin="10" />
        <TextBlock Grid.Row="2" Grid.Column="0" Text="Address" Margin="10" 
                   HorizontalAlignment="Left" VerticalAlignment="Center" />
        <TextBox Grid.Row="2" Grid.Column="1" Margin="10" />
      
    </Grid>
 </Grid>
    public Page()
    {
        InitializeComponent();
        LayoutDesign();
    }

    private void LayoutDesign()
    {
        //Create Stackpanel for ListBox Control and its description
        StackPanel DeptStackPanel = new StackPanel();
        DeptStackPanel.Margin = new Thickness(10);

        LayoutRoot.Children.Add(DeptStackPanel);
        Grid.SetColumn(DeptStackPanel, 1);
        Grid.SetRow(DeptStackPanel, 1);

        TextBlock DeptListHeading = new TextBlock();
        DeptListHeading.Text = "Department";

        ListBox DeptList = new ListBox();
        DeptList.Items.Add("Finance");
        DeptList.Items.Add("Marketing");
        DeptList.Items.Add("Human Resources");
        DeptList.Items.Add("Payroll");

        DeptStackPanel.Children.Add(DeptListHeading);
        DeptStackPanel.Children.Add(DeptList);

        //Create StackPanel for buttons
        StackPanel ButtonsStackPanel = new StackPanel();
        ButtonsStackPanel.Margin = new Thickness(10);
        ButtonsStackPanel.Orientation = Orientation.Horizontal;
        ButtonsStackPanel.HorizontalAlignment = HorizontalAlignment.Center;

        LayoutRoot.Children.Add(ButtonsStackPanel);
        Grid.SetColumn(ButtonsStackPanel, 0);
        Grid.SetRow(ButtonsStackPanel, 2);
        Grid.SetColumnSpan(ButtonsStackPanel, 2);

        Button BackButton = new Button();
        BackButton.Content = "Back";
        BackButton.Width = 100;

        Button CancelButton = new Button();
        CancelButton.Content = "Cancel";
        CancelButton.Width = 100;

        Button NextButton = new Button();
        NextButton.Content = "Next";
        NextButton.Width = 100;

        ButtonsStackPanel.Children.Add(BackButton);
        ButtonsStackPanel.Children.Add(CancelButton);
        ButtonsStackPanel.Children.Add(NextButton);

        BackButton.Margin = new Thickness(10);
        CancelButton.Margin = new Thickness(10);
        NextButton.Margin = new Thickness(10);
    }
}
Partial Public Class Page
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
        LayoutDesign()
    End Sub

    Private Sub LayoutDesign()
        'Create Stackpanel for ListBox Control and its description 
        Dim DeptStackPanel As New StackPanel()
        DeptStackPanel.Margin = New Thickness(10)

        LayoutRoot.Children.Add(DeptStackPanel)
        Grid.SetColumn(DeptStackPanel, 1)
        Grid.SetRow(DeptStackPanel, 1)

        Dim DeptListHeading As New TextBlock()
        DeptListHeading.Text = "Department"

        Dim DeptList As New ListBox()
        DeptList.Items.Add("Finance")
        DeptList.Items.Add("Marketing")
        DeptList.Items.Add("Human Resources")
        DeptList.Items.Add("Payroll")

        DeptStackPanel.Children.Add(DeptListHeading)
        DeptStackPanel.Children.Add(DeptList)

        'Create StackPanel for buttons 
        Dim ButtonsStackPanel As New StackPanel()
        ButtonsStackPanel.Margin = New Thickness(10)
        ButtonsStackPanel.Orientation = Orientation.Horizontal
        ButtonsStackPanel.HorizontalAlignment = HorizontalAlignment.Center

        LayoutRoot.Children.Add(ButtonsStackPanel)
        Grid.SetColumn(ButtonsStackPanel, 0)
        Grid.SetRow(ButtonsStackPanel, 2)
        Grid.SetColumnSpan(ButtonsStackPanel, 2)

        Dim BackButton As New Button()
        BackButton.Content = "Back"
        BackButton.Height = 30
        BackButton.Width = 100

        Dim CancelButton As New Button()
        CancelButton.Content = "Cancel"
        CancelButton.Height = 30
        CancelButton.Width = 100

        Dim NextButton As New Button()
        NextButton.Content = "Next"
        NextButton.Height = 30
        NextButton.Width = 100

        ButtonsStackPanel.Children.Add(BackButton)
        ButtonsStackPanel.Children.Add(CancelButton)
        ButtonsStackPanel.Children.Add(NextButton)

        BackButton.Margin = New Thickness(10)
        CancelButton.Margin = New Thickness(10)
        NextButton.Margin = New Thickness(10)
    End Sub
End Class

備註

提示

如需詳細資訊、設計指引和程式碼範例,請參閱 版面配置面板

Grid 是一種配置面板,可支援排列數據列和數據行中的子元素。

格線配置面板

您通常會在 XAML 中定義 Grid 的配置行為,方法是提供一或多個 RowDefinition 元素做為 Grid.RowDefinitions 的值,以及一或多個 ColumnDefinition 元素做為 Grid.ColumnDefinitions 的值。 然後,您會將 Grid.RowGrid.Column 附加屬性套用至 Grid 的每個元素子系,以指出要使用哪一個數據列/數據行組合將該元素放在父方格內。

若要設定數據列的高度和數據行的寬度,您可以為每個 ColumnDefinition 設定 RowDefinition.HeightColumnDefinition.Width 根據預設,每個數據列或數據行會平均分割版面配置空間。 您可以藉由提供絕對圖元值,或使用加權因數來分割可用空間的 形重設大小來變更此行為。 如需如何在 Grid 中使用星形重設大小的詳細資訊,請參閱使用 XAML 或 GridLength定義版面配置。 您也可以使用大小調整為內容的 自動 重設大小。

若要指出元素子應該跨越 Grid 中的多個資料列或多個數據行,您可以將 Grid.RowSpanGrid.ColumnSpan 附加屬性套用至 Grid 的子元素。

根據預設,Grid 包含一個數據列和一個數據行。

在 Grid 中的子元素上設定 Margin 屬性,會設定元素與其方格單元格界限之間的距離。 HorizontalAlignmentVerticalAlignment 屬性描述子元素應該如何放置在方格單元格內。 您可以使用 Margin 屬性和對齊屬性的組合,精確地定位 Grid 的子元素。 如果您需要更充分掌控個別子元素的配置,請考慮使用 VariableSizedWrapGrid

WrapGrid 是另一個類似的版面配置面板,其優點是較佳地處理過寬的內容,可能會根據其他版面配置屬性的值,由一般 Grid 裁剪。

跨越多個數據列之第一個數據行中的元素可能會影響每個跨越數據列的高度,即使第一個數據列具有足夠的高度來容納元素,後續跨越的數據列也會有0的高度。 例如,此 Grid 中的第二個數據列的高度設定為 0,因此通常看不到藍色矩形。 在此情況下,您可能會預期紅色橢圓形不會影響第二個數據列,因為第一個數據列夠高,足以包含橢圓形。 不過,Grid 會計算每個數據列的 MinHeight 足以容納紅色省略號,然後跨數據列跨越元素。 因此,第二個數據列的MinHeight為50,紅色橢圓形會置中於150px範圍中,而藍色矩形的一半則會顯示在第二個數據列中。

注意

(此範例會使用跨越數據行的專案,但也適用於跨越多個數據列之第一個數據行中的元素。)

<Grid Background="Yellow" Width="300">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="0"/>
    </Grid.RowDefinitions>
    <Ellipse   Grid.Row="0" Grid.Column="0"  Height="50" Fill="Red" Grid.RowSpan="2"/>
    <Rectangle Grid.Row="0" Grid.Column="1" Fill="Green" Height="100"/>
    <Rectangle Grid.Row="1" Grid.Column="1" Fill="Blue" Height="100"/>
</Grid>

框線屬性

Grid 會定義框線屬性,讓您在 Grid 周圍繪製框線,而不需使用額外的 Border 元素。 這些屬性為 Grid.BorderBrushGrid.BorderThicknessGrid.CornerRadiusGrid.Padding

<Grid BorderBrush="Red" BorderThickness="2" CornerRadius="10" Padding="12">
    <TextBlock Text="Hello World!"/>
</Grid>

XAML 附加屬性

Grid 是數個 XAML 附加屬性的主機服務類別。 這些附加屬性可讓子元素報告它們應該如何放置在其 Grid 父系中。

為了支援 XAML 處理器對附加屬性的存取,以及公開對等 的 getset 作業給程式代碼,每個 XAML 附加屬性都有一對 Get 和 Set 存取子方法。 在程序代碼中取得或設定值的另一種方式是使用相依性屬性系統,呼叫 GetValueSetValue 並將識別符字段傳遞為相依性屬性識別碼。

附加屬性 Description
資料行 當父方格配置容器處理子配置時,取得或設定元素的數據行對齊方式。
ColumnSpan 取得或設定值,這個值表示元素內容在父方格內跨越的數據行總數。
資料列 取得或設定父方格配置容器處理子版面配置時元素的數據列對齊方式。
RowSpan 取得或設定值,這個值表示元素內容在父方格內跨越的數據列總數。

版本歷程記錄

Windows 版本 SDK 版本 新增值
1709 16299 ColumnSpacing
1709 16299 RowSpacing
1809 17763 BackgroundSizing

建構函式

Grid()

初始化 Grid 類別的新實例。

屬性

AccessKey

取得或設定這個專案的訪問鍵 (助記鍵) 。

(繼承來源 UIElement)
AccessKeyScopeOwner

取得或設定來源項目,這個元素會提供這個專案的存取索引鍵範圍,即使它不在來源專案的可視化樹狀結構中也一樣。

(繼承來源 UIElement)
ActualHeight

取得 FrameworkElement 的呈現高度。 請參閱<備註>。

(繼承來源 FrameworkElement)
ActualOffset

取得這個 UIElement 的位置,相對於其父系,在配置程式的排列階段期間計算。

(繼承來源 UIElement)
ActualSize

取得這個UIElement在配置程式的排列階段期間計算的大小。

(繼承來源 UIElement)
ActualTheme

取得專案目前使用的UI主題,可能與 RequestedTheme不同。

(繼承來源 FrameworkElement)
ActualWidth

取得 FrameworkElement 的呈現寬度。 請參閱<備註>。

(繼承來源 FrameworkElement)
AllowDrop

取得或設定值,這個值會判斷這個 UIElement 是否可以是拖放作業的置放目標。

(繼承來源 UIElement)
AllowFocusOnInteraction

取得或設定值,這個值表示當使用者與其互動時,專案是否會自動取得焦點。

(繼承來源 FrameworkElement)
AllowFocusWhenDisabled

取得或設定停用的控制項是否可以接收焦點。

(繼承來源 FrameworkElement)
Background

取得或設定填滿面板內容區域的 Brush

(繼承來源 Panel)
BackgroundSizing

取得或設定值,這個值表示背景相對於這個專案框線的延伸距離。

BackgroundSizingProperty

識別 BackgroundSizing 相依性屬性。

BackgroundTransition

取得或設定 BrushTransition 的實例,以自動建立 Background 屬性變更的動畫效果。

(繼承來源 Panel)
BaseUri

取得統一資源識別元 (URI) ,代表 XAML 載入時間 XAML 建構物件的基底統一資源識別元 (URI) 。 此屬性適用於運行時間的統一資源標識碼 (URI) 解析。

(繼承來源 FrameworkElement)
BorderBrush

取得或設定筆刷,描述面板的框線填滿。

BorderBrushProperty

識別 BorderBrush 相依性屬性。

BorderThickness

取得或設定面板的框線粗細。

BorderThicknessProperty

識別 BorderThickness 相依性屬性。

CacheMode

取得或設定值,這個值表示轉譯的內容應該盡可能快取為複合位圖。

(繼承來源 UIElement)
CanBeScrollAnchor

取得或設定值,這個值表示 UIElement 是否可以是捲動錨定候選專案。

(繼承來源 UIElement)
CanDrag

取得或設定值,這個值表示是否可以將專案拖曳為拖放作業中的數據。

(繼承來源 UIElement)
CenterPoint

取得或設定專案的中心點,這是發生旋轉或縮放的點。 影響項目的轉譯位置。

(繼承來源 UIElement)
Children

取得面板子專案的集合。

(繼承來源 Panel)
ChildrenTransitions

取得或設定套用至 Panel 子類別子內容的 Transition 樣式專案集合。

(繼承來源 Panel)
Clip

取得或設定用來定義UIElement內容的大綱的 RectangleGeometry

(繼承來源 UIElement)
ColumnDefinitions

取得在此 Grid 實例上定義的 ColumnDefinition 物件清單。

ColumnProperty

識別 Grid.Column XAML 附加屬性。

ColumnSpacing

取得或設定網格線數據行之間) 圖元 (的統一距離。

ColumnSpacingProperty

識別 ColumnSpacing 相依性屬性。

ColumnSpanProperty

識別 Grid.ColumnSpan XAML 附加屬性。

CompositeMode

取得或設定屬性,這個屬性會宣告其父版面配置和視窗中專案的替代組合和混合模式。 這與混合 XAML/Microsoft DirectX UI 相關的元素相關。

(繼承來源 UIElement)
ContextFlyout

取得或設定與這個項目相關聯的飛出視窗。

(繼承來源 UIElement)
CornerRadius

取得或設定面板框線角落的半徑。

CornerRadiusProperty

識別 CornerRadius 相依性屬性。

DataContext

取得或設定 FrameworkElement 的數據內容。 數據內容的常見用法是 當 FrameworkElement 使用 {Binding} 標記延伸並參與數據系結時。

(繼承來源 FrameworkElement)
DesiredSize

取得這個 UIElement 在版面配置程式的量值階段期間計算的大小。

(繼承來源 UIElement)
Dispatcher

取得與此對象相關聯的 CoreDispatcherCoreDispatcher 代表可以存取 UI 線程上 DependencyObject 的功能,即使程式代碼是由非 UI 線程起始也一樣。

(繼承來源 DependencyObject)
ExitDisplayModeOnAccessKeyInvoked

取得或設定值,指定叫用存取金鑰時是否關閉存取金鑰顯示。

(繼承來源 UIElement)
FlowDirection

取得或設定文字和其他UI元素在控制其版面配置的任何父元素內流動的方向。 這個屬性可以設定為 LeftToRightRightToLeft。 在任何元素上將 FlowDirection 設定為 RightToLeft ,會將對齊方式設定為右側、從右至左的讀取順序,以及控件從右至左流動的版面配置。

(繼承來源 FrameworkElement)
FocusVisualMargin

取得或設定 FrameworkElement 焦點視覺效果的外部邊界。

(繼承來源 FrameworkElement)
FocusVisualPrimaryBrush

取得或設定筆刷,用來繪製 FrameworkElement 之或Reveal焦點視覺效果的外部HighVisibility框線。

(繼承來源 FrameworkElement)
FocusVisualPrimaryThickness

取得或設定 FrameworkElement 之外部Reveal框線的HighVisibility粗細。

(繼承來源 FrameworkElement)
FocusVisualSecondaryBrush

取得或設定筆刷,用來繪製 FrameworkElement 之或Reveal焦點視覺效果的內部HighVisibility框線。

(繼承來源 FrameworkElement)
FocusVisualSecondaryThickness

取得或設定 FrameworkElementHighVisibilityReveal焦點視覺效果的內部框線粗細。

(繼承來源 FrameworkElement)
Height

取得或設定 FrameworkElement 的建議高度。

(繼承來源 FrameworkElement)
HighContrastAdjustment

取得或設定值,這個值表示當啟用高對比度主題時,架構是否會自動調整專案的視覺屬性。

(繼承來源 UIElement)
HorizontalAlignment

取得或設定在版面配置父系中撰寫時套用至 FrameworkElement 的水準對齊特性,例如面板或專案控件。

(繼承來源 FrameworkElement)
IsAccessKeyScope

取得或設定值,這個值表示專案是否定義自己的存取金鑰範圍。

(繼承來源 UIElement)
IsDoubleTapEnabled

取得或設定值,這個值會判斷 DoubleTapped 事件是否可以來自該專案。

(繼承來源 UIElement)
IsHitTestVisible

取得或設定這個 UIElement 的自主區域是否可以傳回真正的值來進行點擊測試。

(繼承來源 UIElement)
IsHoldingEnabled

取得或設定值,這個值會決定 Holding 事件是否可以來自該專案。

(繼承來源 UIElement)
IsItemsHost

取得值,指出此 面板 是否為 ItemsControl 所產生的 UI 專案的容器。

(繼承來源 Panel)
IsLoaded

取得值,這個值表示專案是否已加入至專案樹狀結構,且已準備好進行互動。

(繼承來源 FrameworkElement)
IsRightTapEnabled

取得或設定值,這個值會判斷 RightTapped 事件是否可以來自該專案。

(繼承來源 UIElement)
IsTapEnabled

取得或設定值,這個值會決定 Tapped 事件是否可以來自該專案。

(繼承來源 UIElement)
KeyboardAcceleratorPlacementMode

取得或設定值,這個值表示控件 工具提示 是否顯示其相關聯鍵盤快捷鍵的按鍵組合。

(繼承來源 UIElement)
KeyboardAcceleratorPlacementTarget

取得或設定值,這個值表示顯示快速鍵組合的控件 工具提示

(繼承來源 UIElement)
KeyboardAccelerators

取得使用鍵盤叫用動作的按鍵組合集合。

快捷鍵通常會指派給按鈕或功能表項。

顯示各種功能表項鍵盤快捷鍵的功能表範例
顯示各種功能表項鍵盤快捷鍵的功能表範例

(繼承來源 UIElement)
KeyTipHorizontalOffset

取得或設定值,指出索引鍵提示相對於UIElement的左邊或右邊。

(繼承來源 UIElement)
KeyTipPlacementMode

取得或設定值,這個值表示存取索引鍵提示相對於UIElement界限的位置。

(繼承來源 UIElement)
KeyTipTarget

取得或設定值,這個值表示存取索引鍵提示的目標專案。

(繼承來源 UIElement)
KeyTipVerticalOffset

取得或設定值,這個值表示相對於UI元素放置索引鍵提示的上下距離。

(繼承來源 UIElement)
Language

取得或設定套用至 FrameworkElement 的當地語系化/全球化語言資訊,以及套用至物件表示法和 UI 中目前 FrameworkElement 的所有子元素。

(繼承來源 FrameworkElement)
Lights

取得附加至這個專案的 XamlLight 物件集合。

(繼承來源 UIElement)
ManipulationMode

取得或設定用於UIElement行為與手勢互動的ManipulationModes值。 設定此值可讓您處理來自應用程式程式碼中這個專案的操作事件。

(繼承來源 UIElement)
Margin

取得或設定 FrameworkElement 的外部邊界。

(繼承來源 FrameworkElement)
MaxHeight

取得或設定 FrameworkElement 的最大高度條件約束。

(繼承來源 FrameworkElement)
MaxWidth

取得或設定 FrameworkElement 的最大寬度條件約束。

(繼承來源 FrameworkElement)
MinHeight

取得或設定 FrameworkElement 的最小高度條件約束。

(繼承來源 FrameworkElement)
MinWidth

取得或設定 FrameworkElement 的最小寬度條件約束。

(繼承來源 FrameworkElement)
Name

取得或設定 對象的識別名稱。 當 XAML 處理器從 XAML 標記建立物件樹狀結構時,運行時間程式代碼可以透過這個名稱參考 XAML 宣告的物件。

(繼承來源 FrameworkElement)
Opacity

取得或設定物件的不透明度程度。

(繼承來源 UIElement)
OpacityTransition

取得或設定 ScalarTransition,以動畫顯示 Opacity 屬性的變更。

(繼承來源 UIElement)
Padding

取得或設定框線與其子對象之間的距離。

PaddingProperty

識別 Padding 相依性屬性。

Parent

取得物件樹狀結構中這個 FrameworkElement 的父物件。

(繼承來源 FrameworkElement)
PointerCaptures

取得所有擷取的指標集合,表示為 Pointer 值。

(繼承來源 UIElement)
Projection

取得或設定轉譯這個專案時要套用 (立體效果) 的透視投影。

(繼承來源 UIElement)
RenderSize

取得 UIElement的最終轉譯大小。 不建議使用,請參閱。

(繼承來源 UIElement)
RenderTransform

取得或設定會影響 UIElement轉譯位置的轉換資訊。

(繼承來源 UIElement)
RenderTransformOrigin

取得或設定 RenderTransform 所宣告之任何可能轉譯轉換的原點,相對於 UIElement 的界限。

(繼承來源 UIElement)
RequestedTheme

取得或設定 UIElement (及其子元素) 用於資源判斷的 UI 主題。 您使用 RequestedTheme 指定的 UI 主題可以覆寫應用層級 RequestedTheme

(繼承來源 FrameworkElement)
Resources

取得本機定義的資源字典。 在 XAML 中,您可以透過 XAML 隱含集合語法,將資源專案建立為屬性專案的子物件專案 frameworkElement.Resources

(繼承來源 FrameworkElement)
Rotation

取得或設定順時針旋轉的角度,以度為單位。 相對於 RotationAxis 和 CenterPoint 旋轉。 影響項目的轉譯位置。

(繼承來源 UIElement)
RotationAxis

取得或設定要繞著專案旋轉的軸。

(繼承來源 UIElement)
RotationTransition

取得或設定 ScalarTransition,以動畫顯示 Rotation 屬性的變更。

(繼承來源 UIElement)
RowDefinitions

取得在此 Grid 實例上定義的 RowDefinition 物件清單。

RowProperty

識別 Grid.Row XAML 附加屬性。

RowSpacing

取得或設定網格線列之間) 像素 (的統一距離。

RowSpacingProperty

識別 RowSpacing 相依性屬性。

RowSpanProperty

識別 Grid.RowSpan XAML 附加屬性。

Scale

取得或設定專案的小數位數。 相對於專案的 CenterPoint 縮放比例。 影響項目的轉譯位置。

(繼承來源 UIElement)
ScaleTransition

取得或設定 Vector3Transition,以動畫顯示 Scale 屬性的變更。

(繼承來源 UIElement)
Shadow

取得或設定 專案所轉換的陰影效果。

(繼承來源 UIElement)
Style

取得或設定配置和轉譯期間針對這個物件套用的實例 Style

(繼承來源 FrameworkElement)
TabFocusNavigation

取得或設定值,這個值會修改Tabbing和 TabIndex 對此控件的運作方式。

(繼承來源 UIElement)
Tag

取得或設定任意物件值,可用來儲存這個物件的自定義資訊。

(繼承來源 FrameworkElement)
Transform3D

取得或設定轉譯這個專案時要套用的 3D 轉換效果。

(繼承來源 UIElement)
TransformMatrix

取得或設定要套用至項目的轉換矩陣。

(繼承來源 UIElement)
Transitions

取得或設定套用至 UIElementTransition 樣式專案集合。

(繼承來源 UIElement)
Translation

取得或設定專案的 x、y 和 z 轉譯位置。

(繼承來源 UIElement)
TranslationTransition

取得或設定 Vector3Transition,以動畫顯示 Translation 屬性的變更。

(繼承來源 UIElement)
Triggers

取得針對 FrameworkElement 定義的動畫觸發程式集合。 不常使用。 請參閱<備註>。

(繼承來源 FrameworkElement)
UIContext

取得專案的內容識別碼。

(繼承來源 UIElement)
UseLayoutRounding

取得或設定值,這個值會判斷物件及其視覺子樹的轉譯是否應該使用四捨五入行為,將轉譯對齊整個圖元。

(繼承來源 UIElement)
VerticalAlignment

取得或設定在面板或專案控件等父物件中撰寫時套用至 FrameworkElement 的垂直對齊特性。

(繼承來源 FrameworkElement)
Visibility

取得或設定 UIElement的可見性。 不會轉譯不可見的 UIElement ,也不會將其所需的大小傳達給版面配置。

(繼承來源 UIElement)
Width

取得或設定 FrameworkElement 的寬度。

(繼承來源 FrameworkElement)
XamlRoot

取得或設定 XamlRoot 正在檢視這個專案的 。

(繼承來源 UIElement)
XYFocusDownNavigationStrategy

取得或設定值,指定用來判斷向下瀏覽之目標元素的策略。

(繼承來源 UIElement)
XYFocusKeyboardNavigation

取得或設定值,這個值會啟用或停用使用鍵盤方向箭號的流覽。

(繼承來源 UIElement)
XYFocusLeftNavigationStrategy

取得或設定值,指定用來判斷左側導覽之目標元素的策略。

(繼承來源 UIElement)
XYFocusRightNavigationStrategy

取得或設定值,指定用來判斷右導覽之目標元素的策略。

(繼承來源 UIElement)
XYFocusUpNavigationStrategy

取得或設定值,指定用來判斷向上瀏覽之目標元素的策略。

(繼承來源 UIElement)

附加屬性

Column

取得或設定父方格配置容器處理子版面配置時元素的數據行對齊方式。

ColumnSpan

取得或設定值,這個值表示元素內容在父方格內跨越的數據行總數。

Row

取得或設定父方格配置容器處理子版面配置時元素的數據列對齊方式。

RowSpan

取得或設定值,這個值表示元素內容在父方格內跨越的數據列總數。

方法

AddHandler(RoutedEvent, Object, Boolean)

加入所指定路由事件的路由事件處理常式,會將此處理常式加入目前項目的處理常式集合中。 將 handledEventsToo 指定為 true ,以便叫用提供的處理程式,即使事件是在其他地方處理也一樣。

(繼承來源 UIElement)
Arrange(Rect)

放置子物件,並決定 UIElement的大小。 為其子項目實作自定義配置的父對象應該從其版面配置覆寫實作呼叫此方法,以形成遞歸版面配置更新。

(繼承來源 UIElement)
ArrangeOverride(Size)

提供配置「排列」傳遞的行為。 類別可以覆寫這個方法,以定義自己的「排列」傳遞行為。

(繼承來源 FrameworkElement)
CancelDirectManipulations()

取消任何包含目前 UIElementScrollViewer 父代上 (系統定義的行動瀏覽/縮放) 進行中的直接操作處理。

(繼承來源 UIElement)
CapturePointer(Pointer)

設定 UIElement 的指標擷取。 擷取之後,只有具有擷取的專案才會引發指標相關事件。

(繼承來源 UIElement)
ClearValue(DependencyProperty)

清除相依性屬性的本機值。

(繼承來源 DependencyObject)
FindName(String)

擷取具有指定標識碼名稱的物件。

(繼承來源 FrameworkElement)
FindSubElementsForTouchTargeting(Point, Rect)

可讓 UIElement 子類別公開可協助解決觸控目標的子元素。

(繼承來源 UIElement)
GetAnimationBaseValue(DependencyProperty)

傳回針對相依性屬性所建立的任何基底值,如果動畫未使用中,則會套用。

(繼承來源 DependencyObject)
GetBindingExpression(DependencyProperty)

會傳回代表指定屬性上系結的 BindingExpression

(繼承來源 FrameworkElement)
GetChildrenInTabFocusOrder()

可讓 UIElement 子類別公開參與 Tab 焦點的子元素。

(繼承來源 UIElement)
GetColumn(FrameworkElement)

從指定的 FrameworkElement 取得 Grid.Column XAML 附加屬性的值。

GetColumnSpan(FrameworkElement)

從指定的 FrameworkElement 取得 Grid.ColumnSpan XAML 附加屬性的值。

GetRow(FrameworkElement)

從指定的 FrameworkElement 取得 Grid.Row XAML 附加屬性的值。

GetRowSpan(FrameworkElement)

從指定的 FrameworkElement 取得 Grid.RowSpan XAML 附加屬性的值。

GetValue(DependencyProperty)

DependencyObject 傳回相依性屬性的目前有效值。

(繼承來源 DependencyObject)
GoToElementStateCore(String, Boolean)

在衍生類別中實作時,可在程式碼中啟用控件範本的個別狀態建構可視化樹狀結構,而不是在控件啟動時載入所有狀態的 XAML。

(繼承來源 FrameworkElement)
InvalidateArrange()

使 UIElement 的排列狀態 (配置) 失效。 無效之後, UIElement 會更新其版面配置,這會以異步方式發生。

(繼承來源 UIElement)
InvalidateMeasure()

使 UIElement的度量狀態 (配置) 失效。

(繼承來源 UIElement)
InvalidateViewport()

使用來計算有效檢視區的UIElement檢視區狀態失效。

(繼承來源 FrameworkElement)
Measure(Size)

匯報 UIElementDesiredSize。 一般而言,實作其版面配置子系之自定義配置的物件會從自己的 MeasureOverride 實作呼叫此方法,以形成遞歸版面配置更新。

(繼承來源 UIElement)
MeasureOverride(Size)

提供配置週期的「量值」傳遞行為。 類別可以覆寫這個方法,以定義自己的「量值」傳遞行為。

(繼承來源 FrameworkElement)
OnApplyTemplate()

每當應用程式程式代碼或內部進程 (,例如重建版面配置傳遞) 呼叫 ApplyTemplate 時叫用。 在最簡單的詞彙中,這表示方法只會在應用程式中顯示UI元素之前呼叫。 覆寫這個方法,以影響類別的默認範本後邏輯。

(繼承來源 FrameworkElement)
OnBringIntoViewRequested(BringIntoViewRequestedEventArgs)

在 BringIntoViewRequested 事件發生之前呼叫。

(繼承來源 UIElement)
OnCreateAutomationPeer()

在衍生類別中實作時,會傳回 Microsoft 使用者介面自動化 基礎結構的類別特定 AutomationPeer 實作。

(繼承來源 UIElement)
OnDisconnectVisualChildren()

覆寫這個方法,以實作從類別特定內容或子屬性移除專案時配置和邏輯的行為。

(繼承來源 UIElement)
OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs)

在應用程式中處理 鍵盤快捷方式 (或快捷鍵) 時呼叫。 覆寫這個方法,以處理叫用鍵盤快捷方式時您的應用程式回應方式。

(繼承來源 UIElement)
OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs)

在應用程式中處理 鍵盤快捷方式 (或快捷鍵) 之前呼叫。 每當應用程式程式代碼或內部進程呼叫 ProcessKeyboardAccelerators 時叫用。 覆寫此方法以影響預設加速器處理。

(繼承來源 UIElement)
PopulatePropertyInfo(String, AnimationPropertyInfo)

定義可以產生動畫效果的屬性。

(繼承來源 UIElement)
PopulatePropertyInfoOverride(String, AnimationPropertyInfo)

在衍生類別中覆寫時,定義可以產生動畫效果的屬性。

(繼承來源 UIElement)
ReadLocalValue(DependencyProperty)

如果已設定本機值,則傳回相依性屬性的本機值。

(繼承來源 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

註冊通知函式,以接聽此 DependencyObject 實例上特定 DependencyProperty 的變更。

(繼承來源 DependencyObject)
ReleasePointerCapture(Pointer)

釋放指標擷取,以供這個 UIElement擷取一個特定指標。

(繼承來源 UIElement)
ReleasePointerCaptures()

釋放這個專案保留的所有指標擷取。

(繼承來源 UIElement)
RemoveHandler(RoutedEvent, Object)

從這個 UIElement 移除指定的路由事件處理程式。 通常會由 AddHandler 新增有問題的處理程式。

(繼承來源 UIElement)
SetBinding(DependencyProperty, BindingBase)

使用提供的系結物件,將系結附加至 FrameworkElement

(繼承來源 FrameworkElement)
SetColumn(FrameworkElement, Int32)

在指定的 FrameworkElement 上設定 Grid.Column XAML 附加屬性的值。

SetColumnSpan(FrameworkElement, Int32)

在指定的 FrameworkElement 上設定 Grid.ColumnSpan XAML 附加屬性的值。

SetRow(FrameworkElement, Int32)

在指定的 FrameworkElement 上設定 Grid.Row XAML 附加屬性的值。

SetRowSpan(FrameworkElement, Int32)

在指定的 FrameworkElement 上設定 Grid.RowSpan XAML 附加屬性的值。

SetValue(DependencyProperty, Object)

DependencyObject 上設定相依性屬性的本機值。

(繼承來源 DependencyObject)
StartAnimation(ICompositionAnimationBase)

開始專案上的指定動畫。

(繼承來源 UIElement)
StartBringIntoView()

起始 XAML 架構的要求,以將元素帶入其內含之任何可捲動區域內的檢視。

(繼承來源 UIElement)
StartBringIntoView(BringIntoViewOptions)

初始化 XAML 架構的要求,以使用指定的選項將專案帶入檢視。

(繼承來源 UIElement)
StartDragAsync(PointerPoint)

啟始拖放作業。

(繼承來源 UIElement)
StopAnimation(ICompositionAnimationBase)

停止元素上的指定動畫。

(繼承來源 UIElement)
TransformToVisual(UIElement)

傳回轉換物件,可用來將 UIElement 的座標轉換為指定的物件。

(繼承來源 UIElement)
TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs)

嘗試搜尋 UIElement 的整個可視化樹狀結構, 以叫用鍵盤快捷方式 (或快捷鍵)

(繼承來源 UIElement)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消先前透過呼叫 RegisterPropertyChangedCallback 註冊的變更通知。

(繼承來源 DependencyObject)
UpdateLayout()

確保 UIElement 子物件的所有位置都已針對版面配置正確更新。

(繼承來源 UIElement)

事件

AccessKeyDisplayDismissed

發生於不應再顯示存取金鑰時。

(繼承來源 UIElement)
AccessKeyDisplayRequested

發生於使用者要求顯示存取金鑰時。

(繼承來源 UIElement)
AccessKeyInvoked

發生於使用者完成存取金鑰序列時。

(繼承來源 UIElement)
ActualThemeChanged

發生於 ActualTheme 屬性值已變更時。

(繼承來源 FrameworkElement)
BringIntoViewRequested

在這個專案或其中一個子代上呼叫 StartBringIntoView 時發生。

(繼承來源 UIElement)
CharacterReceived

發生於輸入佇列收到單一、撰寫的字元時。

(繼承來源 UIElement)
ContextCanceled

發生於內容輸入手勢繼續進入操作手勢時,通知專案不應開啟內容飛出視窗。

(繼承來源 UIElement)
ContextRequested

發生於使用者已完成內容輸入手勢時,例如按兩下滑鼠右鍵。

(繼承來源 UIElement)
DataContextChanged

發生於 FrameworkElement.DataContext 屬性的值變更時。

(繼承來源 FrameworkElement)
DoubleTapped

發生於在此元素的點擊測試區域上發生未處理的 DoubleTap 互動時。

(繼承來源 UIElement)
DragEnter

當輸入系統報告基礎拖曳事件,並將這個項目當做目標時發生。

(繼承來源 UIElement)
DragLeave

當輸入系統報告基礎拖曳事件,並將這個項目當做原點時發生。

(繼承來源 UIElement)
DragOver

在輸入系統回報以此項目作為可能置放目標的基礎拖曳事件時發生。

(繼承來源 UIElement)
DragStarting

發生於起始拖曳作業時。

(繼承來源 UIElement)
Drop

輸入系統報告其下以這個項目作為置放目標的置放事件時發生。

(繼承來源 UIElement)
DropCompleted

發生於以這個專案做為結束來源的拖放作業時。

(繼承來源 UIElement)
EffectiveViewportChanged

發生於 FrameworkElement的有效檢視區 變更時。

(繼承來源 FrameworkElement)
GettingFocus

發生於 UIElement 收到焦點之前。 此事件會同步引發,以確保事件反升時不會移動焦點。

(繼承來源 UIElement)
GotFocus

發生於 UIElement 收到焦點時。 此事件會以異步方式引發,因此焦點可以在反升完成之前再次移動。

(繼承來源 UIElement)
Holding

發生於在此元素的點擊測試區域上發生未處理的 保留 互動時。

(繼承來源 UIElement)
KeyDown

UIElement 有焦點時按下鍵盤按鍵時發生。

(繼承來源 UIElement)
KeyUp

發生於 UIElement 有焦點時放開鍵盤按鍵時。

(繼承來源 UIElement)
LayoutUpdated

發生於可視化樹狀結構的版面配置變更時,因為配置相關屬性變更值或重新整理版面配置的其他動作。

(繼承來源 FrameworkElement)
Loaded

發生於 架構Element 已建構並新增至物件樹狀結構,並準備好進行互動時。

(繼承來源 FrameworkElement)
Loading

FrameworkElement 開始載入時發生。

(繼承來源 FrameworkElement)
LosingFocus

發生於 UIElement 失去焦點之前。 此事件會同步引發,以確保事件反升時不會移動焦點。

(繼承來源 UIElement)
LostFocus

發生於 UIElement 失去焦點時。 這個事件會以異步方式引發,因此焦點可以在反升完成之前再次移動。

(繼承來源 UIElement)
ManipulationCompleted

發生於 UIElement 上的操作完成時。

(繼承來源 UIElement)
ManipulationDelta

輸入裝置在操作期間變更位置時發生。

(繼承來源 UIElement)
ManipulationInertiaStarting

在操作和慣性開始的時候,只要輸入裝置不與 UIElement 物件接觸便發生。

(繼承來源 UIElement)
ManipulationStarted

當輸入裝置開始在 UIElement 進行操作時發生。

(繼承來源 UIElement)
ManipulationStarting

發生於第一次建立操作處理器時。

(繼承來源 UIElement)
NoFocusCandidateFound

發生於用戶嘗試透過定位鍵或方向箭號 (移動焦點時) ,但焦點不會移動,因為沒有在移動方向找到焦點候選專案。

(繼承來源 UIElement)
PointerCanceled

發生於讓聯繫人異常遺失聯繫人的指標時。

(繼承來源 UIElement)
PointerCaptureLost

發生於此元素先前保留的指標擷取移至另一個專案或其他地方時。

(繼承來源 UIElement)
PointerEntered

發生於指標進入這個項目的點擊測試區域時。

(繼承來源 UIElement)
PointerExited

發生於指標離開這個項目的點擊測試區域時。

(繼承來源 UIElement)
PointerMoved

當指標在指標保留在這個項目的點擊測試區域中時移動時發生。

(繼承來源 UIElement)
PointerPressed

發生於指標裝置起始這個專案內的 Press 動作時。

(繼承來源 UIElement)
PointerReleased

發生於先前起始 「按下」 動作的指標裝置釋放時,同時在此元素內。 請注意, Press 動作的結尾不保證會引發 PointerReleased 事件;其他事件可能會改為引發。 如需詳細資訊,請參閱。

(繼承來源 UIElement)
PointerWheelChanged

發生於指標滾輪的差異值變更時。

(繼承來源 UIElement)
PreviewKeyDown

發生於 UIElement 有焦點時按下鍵盤按鍵時。

(繼承來源 UIElement)
PreviewKeyUp

發生於 UIElement 有焦點時放開鍵盤按鍵時。

(繼承來源 UIElement)
ProcessKeyboardAccelerators

發生於按下 鍵盤快捷方式 (或快捷鍵) 時。

(繼承來源 UIElement)
RightTapped

發生於指標位於元素上方時發生右點選輸入壓力時。

(繼承來源 UIElement)
SizeChanged

發生於 ActualHeightActualWidth 屬性變更 FrameworkElement 上的值時。

(繼承來源 FrameworkElement)
Tapped

發生於此元素的點擊測試區域上發生未處理的 Tap 互動時。

(繼承來源 UIElement)
Unloaded

當這個物件不再連接到主物件樹狀結構時發生。

(繼承來源 FrameworkElement)

適用於

另請參閱