GridView markup reference
GridView and its columns.
GridViewColumn<TItem>
Section titled “GridViewColumn<TItem>”Receiver: GridViewColumn<TItem>.
| Method | Sets | Summary |
|---|---|---|
AutoWidth(double minWidth = 0, double maxWidth = double.PositiveInfinity) |
Sets an Auto width together with its constraints. | |
Bind(Func<TemplateContext, TElement> build, Action<TElement, TItem, int, TemplateContext> bind, Action<TElement, TItem, int, TemplateContext> unbind = null) |
Sets the cell template using delegate-based templating. | |
Bind(Func<TemplateContext, TElement> build, Action<TElement, TItem> bind) |
Sets the cell template using delegate-based templating with a simple bind callback. | |
Bind(IDataTemplate<TItem> template) |
Sets the column cell template. | |
CellTemplate(IDataTemplate<TItem> value) |
CellTemplate |
Sets the template that builds a row’s cell for this column. |
Header(string header) |
Header |
Sets the column header text. |
HeaderTextAlignment(TextAlignment value) |
HeaderTextAlignment |
Sets the horizontal alignment of the header text. |
IsResizable(bool value = true) |
IsResizable |
Sets whether the column can be resized by dragging the header separator. |
MaxWidth(double value) |
MaxWidth |
Sets the maximum column width enforced by layout and resize; the default is positive infinity. |
MinWidth(double value) |
MinWidth |
Sets the minimum column width enforced during resize; 0 (the default) means no minimum. |
PixelWidth(double width, double minWidth = 0, double maxWidth = double.PositiveInfinity) |
Sets a fixed pixel width together with its constraints. | |
Resizable(bool resizable = true) |
Sets whether the column can be resized by dragging the header separator. | |
SortBy(Func<TItem, TKey> keySelector, IComparer<TKey> comparer = null) |
Enables sorting by a key selected from each row item. | |
SortWith(IComparer<TItem> comparer) |
SortComparer |
Enables sorting with a comparer over complete row items. |
StarWidth(double weight = 1, double minWidth = 0, double maxWidth = double.PositiveInfinity) |
Sets a Star width with the given weight together with its constraints. | |
Template(Func<TemplateContext, TElement> build, Action<TElement, TItem, int, TemplateContext> bind, Action<TElement, TItem, int, TemplateContext> unbind = null) |
Sets the cell template using delegate-based templating. | |
Template(Func<TemplateContext, TElement> build, Action<TElement, TItem> bind) |
Sets the cell template using delegate-based templating with a simple bind callback. Alias for Bind. | |
Template(IDataTemplate<TItem> template) |
Sets the cell template. Alias for Bind. | |
Text(Func<TItem, string> textSelector) |
Sets a text-based cell template that displays the result of textSelector. | |
Width(GridLength width, double minWidth = 0, double maxWidth = double.PositiveInfinity) |
Width, MinWidth, MaxWidth |
Sets an Auto, Star, or Pixel width together with its constraints. |
Width(double width) |
Width |
Sets the column width. |
Width(double width, double minWidth, double maxWidth) |
Sets a fixed pixel width together with its constraints. |
GridView
Section titled “GridView”Receiver: GridView.
| Method | Sets | Summary |
|---|---|---|
AddColumn(string header, GridLength width, Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, Action<FrameworkElement, TItem, int, TemplateContext> unbind, double minWidth = 0, double maxWidth = double.PositiveInfinity, bool resizable = true) |
Adds an Auto, Star, or Pixel column using delegate-based templating with an unbind callback. | |
AddColumn(string header, GridLength width, Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, double minWidth = 0, double maxWidth = double.PositiveInfinity, bool resizable = true) |
Adds an Auto, Star, or Pixel column using delegate-based templating. | |
AddColumn(string header, GridLength width, IDataTemplate<TItem> template, double minWidth = 0, double maxWidth = double.PositiveInfinity, bool resizable = true) |
Adds a column using Auto, Star, or Pixel sizing. | |
AddColumn(string header, double width, Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, Action<FrameworkElement, TItem, int, TemplateContext> unbind, double minWidth = 0, bool resizable = true) |
Adds a column using delegate-based templating with an unbind callback. | |
AddColumn(string header, double width, Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, Action<FrameworkElement, TItem, int, TemplateContext> unbind, double minWidth, double maxWidth, bool resizable = true) |
Adds a fixed-width column with minimum and maximum constraints using delegate-based templating with an unbind callback. | |
AddColumn(string header, double width, Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, double minWidth = 0, bool resizable = true) |
Adds a column using delegate-based templating. | |
AddColumn(string header, double width, Func<TemplateContext, FrameworkElement> build, Action<FrameworkElement, TItem, int, TemplateContext> bind, double minWidth, double maxWidth, bool resizable = true) |
Adds a fixed-width column with minimum and maximum constraints using delegate-based templating. | |
AddColumn(string header, double width, IDataTemplate<TItem> template, double minWidth = 0, bool resizable = true) |
Adds a column. | |
AddColumn(string header, double width, IDataTemplate<TItem> template, double minWidth, double maxWidth, bool resizable = true) |
Adds a fixed-width column with minimum and maximum constraints. | |
CellPadding(Thickness value) |
CellPadding |
Sets the padding applied to each cell. |
ClearContainer(PrepareContainerHandler<GridViewRow, T> clear) |
Releases what PrepareContainer attached outside the template context, before the row takes another item. | |
Columns(params GridViewColumn<TItem>[] columns) |
Adds one or more columns to the grid view. | |
FixedHeightPresenter() |
Uses fixed-height row virtualization (default). Rows assume RowHeight or the theme default; cell content taller than that clips. | |
HeaderHeight(double value) |
HeaderHeight |
Sets the header row height in DIPs; NaN uses the theme default. |
ItemsSource(IReadOnlyList<TItem> items) |
ItemsSource |
Sets ItemsSource to a view over the list. |
ItemsSource(ItemsView<TItem> itemsView) |
ItemsSource |
Sets ItemsSource to the view. |
MaxAutoViewportHeight(double value) |
MaxAutoViewportHeight |
Sets the maximum height, in DIPs, the rows viewport grows to when the grid sizes to its content. |
OnItemDoubleClicked(Action<object> handler) |
event ItemDoubleClicked |
Subscribes handler to ItemDoubleClicked. Occurs when a row is double-clicked with the primary mouse button. |
OnSelectedIndicesChanged(Action handler) |
event SelectedIndicesChanged |
Subscribes handler to SelectedIndicesChanged. Occurs when the set of selected rows changes (multi-select). |
OnSelectionChanged(Action<object> handler) |
event SelectionChanged |
Subscribes handler to SelectionChanged. Occurs when the selected row changes. |
OnSortChanged(Action<GridViewSortChange> handler) |
event SortChanged |
Adds a sort changed event handler. |
PrepareContainer(PrepareContainerHandler<GridViewRow, T> prepare) |
Configures each row once its cells are bound, so behavior can be attached to the whole row instead of being repeated in every cell template. The row is the container the grid already realizes, so no extra element is created. | |
RowHeight(double value) |
RowHeight |
Sets the row height in DIPs; NaN uses the theme default. |
SelectedIndex(int value) |
SelectedIndex |
Sets the selected row index, or -1 when nothing is selected. |
SelectedItem(object value) |
SelectedItem |
Sets the selected item, or null when nothing is selected. |
SelectionMode(ItemsSelectionMode value) |
SelectionMode |
Sets the selection mode; multi-selection needs an items source that supports it (e.g. from Create ), otherwise the mode stays Single. |
ShowGridLines(bool value = true) |
ShowGridLines |
Sets whether lines are drawn between rows and columns. |
SortByColumn(int columnIndex, GridViewSortDirection direction = Ascending) |
Applies an initial local single-column sort. | |
VariableHeightPresenter() |
Uses variable-height row virtualization. Each row’s height is the maximum measured cell height plus CellPadding vertical thickness - suitable for rows with wrapping text or differently sized cell content. | |
ZebraStriping(bool value = true) |
ZebraStriping |
Sets whether alternating rows use a second background color (zebra striping). |