Class Grid
Defines a flexible grid area that consists of columns and rows. Child elements
of the Grid are measured and arranged according to their row/column assignments
and internal partial class logic.
Inheritance
System.Object
Grid
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: OpenSilver.dll
Syntax
public class Grid : Panel
Examples
You can add a Grid with two rows and columns to the XAML as follows:
Or in C#:
Grid myGrid = new Grid();
myGrid.Width = 300;
myGrid.Height = 200;
myGrid.Background = new SolidColorBrush(Windows.UI.Colors.Blue);
myGrid.HorizontalAlignment = HorizontalAlignment.Left;
//We create and add the rows and columns:
//First column:
ColumnDefinition columnDefinition = new ColumnDefinition();
columnDefinition.Width = new GridLength(70, GridUnitType.Pixel);
myGrid.ColumnDefinitions.Add(columnDefinition);
//Second column:
ColumnDefinition columnDefinition2 = new ColumnDefinition();
columnDefinition2.Width = new GridLength(1, GridUnitType.Star);
myGrid.ColumnDefinitions.Add(columnDefinition2);
//First row:
RowDefinition rowDefinition = new RowDefinition();
rowDefinition.Height = new GridLength(40, GridUnitType.Pixel);
myGrid.RowDefinitions.Add(rowDefinition);
//Second Row:
RowDefinition rowDefinition2 = new RowDefinition();
rowDefinition2.Height = new GridLength(1, GridUnitType.Star);
myGrid.RowDefinitions.Add(rowDefinition2);
//Do not forget to add the Grid to the visual tree.
Constructors
|
Improve this Doc
View Source
Grid()
Initializes a new instance of the Grid class.
Declaration
Fields
|
Improve this Doc
View Source
ColumnProperty
Identifies the Grid.Column XAML attached property
Declaration
public static readonly DependencyProperty ColumnProperty
Field Value
|
Improve this Doc
View Source
ColumnSpanProperty
Declaration
public static readonly DependencyProperty ColumnSpanProperty
Field Value
|
Improve this Doc
View Source
RowProperty
Identifies the Grid.Row XAML attached property.
Declaration
public static readonly DependencyProperty RowProperty
Field Value
|
Improve this Doc
View Source
RowSpanProperty
Declaration
public static readonly DependencyProperty RowSpanProperty
Field Value
|
Improve this Doc
View Source
ShowGridLinesProperty
Declaration
[NotImplemented]
public static readonly DependencyProperty ShowGridLinesProperty
Field Value
Properties
|
Improve this Doc
View Source
ColumnDefinitions
Gets a list of ColumnDefinition objects defined on this instance of Grid.
Declaration
public ColumnDefinitionCollection ColumnDefinitions { get; }
Property Value
|
Improve this Doc
View Source
RowDefinitions
Gets a list of RowDefinition objects defined on this instance of Grid.
Declaration
public RowDefinitionCollection RowDefinitions { get; }
Property Value
|
Improve this Doc
View Source
ShowGridLines
Declaration
[NotImplemented]
public bool ShowGridLines { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
|
Improve this Doc
View Source
ArrangeOverride(Size)
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type |
Name |
Description |
Size |
finalSize |
|
Returns
Overrides
|
Improve this Doc
View Source
CreateDomChildWrapper(Object, out Object, Int32)
Declaration
public override object CreateDomChildWrapper(object parentRef, out object domElementWhereToPlaceChild, int index = -1)
Parameters
Type |
Name |
Description |
System.Object |
parentRef |
|
System.Object |
domElementWhereToPlaceChild |
|
System.Int32 |
index |
|
Returns
Type |
Description |
System.Object |
|
Overrides
|
Improve this Doc
View Source
CreateDomElement(Object, out Object)
Declaration
public override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
Type |
Name |
Description |
System.Object |
parentRef |
|
System.Object |
domElementWhereToPlaceChildren |
|
Returns
Type |
Description |
System.Object |
|
Overrides
|
Improve this Doc
View Source
GetColumn(UIElement)
Gets the value of the Grid.Column XAML attached property from the specified
FrameworkElement.
Declaration
public static int GetColumn(UIElement element)
Parameters
Type |
Name |
Description |
UIElement |
element |
The element from which to read the property value.
|
Returns
Type |
Description |
System.Int32 |
The value of the Grid.Column XAML attached property on the target element.
|
|
Improve this Doc
View Source
GetColumnSpan(UIElement)
Declaration
public static int GetColumnSpan(UIElement element)
Parameters
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
GetDomElementWhereToPlaceChild(UIElement)
Declaration
public override object GetDomElementWhereToPlaceChild(UIElement child)
Parameters
Returns
Type |
Description |
System.Object |
|
Overrides
|
Improve this Doc
View Source
GetRow(UIElement)
Gets the value of the Grid.Row XAML attached property from the specified
FrameworkElement.
Declaration
public static int GetRow(UIElement element)
Parameters
Type |
Name |
Description |
UIElement |
element |
The element from which to read the property value.
|
Returns
Type |
Description |
System.Int32 |
The value of the Grid.Row XAML attached property on the target element.
|
|
Improve this Doc
View Source
GetRowSpan(UIElement)
Declaration
public static int GetRowSpan(UIElement element)
Parameters
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
INTERNAL_OnDetachedFromVisualTree()
Declaration
protected override void INTERNAL_OnDetachedFromVisualTree()
Overrides
|
Improve this Doc
View Source
MeasureOverride(Size)
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type |
Name |
Description |
Size |
availableSize |
|
Returns
Overrides
|
Improve this Doc
View Source
SetColumn(UIElement, Int32)
Sets the value of the Grid.Column XAML attached property on the specified FrameworkElement.
Declaration
public static void SetColumn(UIElement element, int value)
Parameters
Type |
Name |
Description |
UIElement |
element |
The target element on which to set the Grid.Row XAML attached property.
|
System.Int32 |
value |
The property value to set.
|
|
Improve this Doc
View Source
SetColumnSpan(UIElement, Int32)
Declaration
public static void SetColumnSpan(UIElement element, int value)
Parameters
Type |
Name |
Description |
UIElement |
element |
|
System.Int32 |
value |
|
|
Improve this Doc
View Source
SetRow(UIElement, Int32)
Sets the value of the Grid.Row XAML attached property on the specified FrameworkElement.
Declaration
public static void SetRow(UIElement element, int value)
Parameters
Type |
Name |
Description |
UIElement |
element |
The target element on which to set the Grid.Row XAML attached property.
|
System.Int32 |
value |
The property value to set.
|
|
Improve this Doc
View Source
SetRowSpan(UIElement, Int32)
Declaration
public static void SetRowSpan(UIElement element, int value)
Parameters
Type |
Name |
Description |
UIElement |
element |
|
System.Int32 |
value |
|
Extension Methods