Class TreeGridColumnSizer
Represents a class that provides the implementation to calculate column widths based on different column sizer options for SfTreeGrid(TreeColumnSizer).
Implements
Inherited Members
Namespace: Syncfusion.UI.Xaml.TreeGrid
Assembly: Syncfusion.SfGrid.WPF.dll
Syntax
public class TreeGridColumnSizer : ColumnSizerBase<SfTreeGrid>, IDisposable
Constructors
TreeGridColumnSizer()
Initializes a new instance of TreeGridColumnSizer class.
Declaration
public TreeGridColumnSizer()
TreeGridColumnSizer(SfTreeGrid)
Initializes a new instance of TreeGridColumnSizer class with specififed SfTreeGrid.
Declaration
public TreeGridColumnSizer(SfTreeGrid treeGrid)
Parameters
Type | Name | Description |
---|---|---|
SfTreeGrid | treeGrid | The SfTreeGrid. |
Properties
CheckBoxWidth
Gets or sets the width of node check box for column width calculation when ShowCheckBox is true.
Declaration
public double CheckBoxWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The width of the CheckBox. The default value is 24. |
ExpanderWidth
Gets or sets the width of expander for column width calculation
Declaration
public double ExpanderWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The width of the expander. The default value is 18. |
TreeGrid
Gets the reference to the SfTreeGrid control.
Declaration
protected SfTreeGrid TreeGrid { get; }
Property Value
Type |
---|
SfTreeGrid |
Methods
CalculateAutoFitWidth(TreeGridColumn)
Calculates the width for the column to fit the content when column sizer is Auto.
Declaration
protected virtual double CalculateAutoFitWidth(TreeGridColumn column)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to calculate the width when column sizer is Auto. |
Returns
Type | Description |
---|---|
System.Double | Returns the column width based on Auto column sizer. |
Remarks
Override this method and customize the calculation of Auto column sizer.
CalculateCellWidth(TreeGridColumn)
Calculates the width for the column based on cell value when column sizer is SizeToCells or Auto.
Declaration
protected virtual double CalculateCellWidth(TreeGridColumn column)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to calculate the cell width based on cell value. |
Returns
Type | Description |
---|---|
System.Double | Returns the corresponding width for the specified column. |
Remarks
This method is invoked when the column sizer is SizeToCells or Auto and you can customize column width calculation by overriding this method.
CalculateExpanderColumnWidth(TreeGridColumn, Double)
Calculate expander column width by considering expander cell, CheckBox, MinWidth and MaxWidth.
Declaration
protected virtual double CalculateExpanderColumnWidth(TreeGridColumn column, double width)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | the expander column. |
System.Double | width | the column width. |
Returns
Type | Description |
---|---|
System.Double | calculated width. |
CalculateHeaderWidth(TreeGridColumn)
Calculates the width of the column based on header text when column sizer is SizeToHeader or Auto.
Declaration
protected virtual double CalculateHeaderWidth(TreeGridColumn column)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to calculate its header width. |
Returns
Type | Description |
---|---|
System.Double | Returns the width of the specified column. |
Remarks
This method is invoked when the column sizer is SizeToHeader or Auto and you can customize column width calculation by overriding this method.
ChangeExpanderColumnWidth()
Change expander column width based on node's level.
Declaration
protected virtual void ChangeExpanderColumnWidth()
Dispose(Boolean)
Disposes all the resources used by the TreeGridColumnSizer class.
Declaration
protected override void Dispose(bool isDisposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isDisposing | Indicates whether the call is from Dispose method or from a finalizer. |
Overrides
GetCellSize(Size, TreeGridColumn, TreeNode, GridQueryBounds)
Gets the size of the cell to calculate the width of the specified column when column sizer is SizeToCells or Auto.
Declaration
protected virtual Size GetCellSize(Size rect, TreeGridColumn column, TreeNode node, GridQueryBounds bounds)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Size | rect | The corresponding display rectangle of the cell to measure cell size. |
TreeGridColumn | column | The corresponding column to measure its cell size. |
TreeNode | node | The corresponding node to measure the text size in cell. |
GridQueryBounds | bounds | Indicates whether the cell size is measured based on the height or width of the cell. |
Returns
Type | Description |
---|---|
System.Windows.Size | Returns the size of the cell. |
GetColumnToFill()
Gets the column to fill the remaining view port size based on AutoFillColumn or FillColumn column sizer.
Declaration
protected virtual TreeGridColumn GetColumnToFill()
Returns
Type | Description |
---|---|
TreeGridColumn | the column to fill. |
GetControl(TreeGridColumn, Object)
Gets the content control to measure the template when column sizer is SizeToCells or Auto.
Declaration
protected virtual ContentControl GetControl(TreeGridColumn column, object record)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to get the content control. |
System.Object | record | The corresponding record to get the content control. |
Returns
Type | Description |
---|---|
System.Windows.Controls.ContentControl | Returns the System.Windows.Controls.ContentControl for the specified column and record. |
GetDisplayText(TreeGridColumn, Object)
Gets the display text of cell for the specified column and data.
Declaration
protected virtual string GetDisplayText(TreeGridColumn column, object data)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to get the display text of cell. |
System.Object | data | The corresponding record to get the display text. |
Returns
Type | Description |
---|---|
System.String | Returns the display text of the corresponding column. |
GetExpanderColumn()
Gets the column in which expander cell is loaded.
Declaration
protected TreeGridColumn GetExpanderColumn()
Returns
Type | Description |
---|---|
TreeGridColumn | the expander column. |
GetFormattedText(TreeGridColumn, Object, String)
Gets the formatted text for the specified column.
Declaration
protected virtual FormattedText GetFormattedText(TreeGridColumn column, object record, string displaytext)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to get the formatted text. |
System.Object | record | The corresponding record to get the formatted text. |
System.String | displaytext | The corresponding display text to get formatted text. |
Returns
Type | Description |
---|---|
System.Windows.Media.FormattedText | Returns the formatted text for the specified column. |
GetTextBlock(TreeGridColumn, Object, GridQueryBounds)
Gets the TextBlock to measure the text when the column sizer is SizeToCells or Auto.
Declaration
protected virtual TextBlock GetTextBlock(TreeGridColumn column, object record, GridQueryBounds queryBounds)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to get the TextBlock. |
System.Object | record | The corresponding record to get the TextBlock. |
GridQueryBounds | queryBounds | Indicates whether the text is measured based on the height or width of the cell. |
Returns
Type | Description |
---|---|
System.Windows.Controls.TextBlock | Returns the TextBlock for the specified column and record. |
MeasureHeaderTemplate(TreeGridColumn, Size, GridQueryBounds)
Measures the size of the header template for the specified column when the column sizer is SizeToHeader or Auto.
Declaration
protected virtual Size MeasureHeaderTemplate(TreeGridColumn column, Size rect, GridQueryBounds bounds)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to measure the header template. |
System.Windows.Size | rect | The corresponding display rectangle to measure the template. |
GridQueryBounds | bounds | Indicates whether the template is measured based on the height or width of the cell. |
Returns
Type | Description |
---|---|
System.Windows.Size | Returns the size of the header template for the specified column. |
MeasureTemplate(Size, Object, TreeGridColumn, GridQueryBounds)
Measures the size of the template when the column sizer is SizeToCells or Auto.
Declaration
protected virtual Size MeasureTemplate(Size rect, object record, TreeGridColumn column, GridQueryBounds bounds)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Size | rect | The corresponding display rectangle to measure the template. |
System.Object | record | The corresponding record to measure the template. |
TreeGridColumn | column | The corresponding column to measure the template. |
GridQueryBounds | bounds | Indicates whether the template is measured based on the height or width of the cell. |
Returns
Type | Description |
---|---|
System.Windows.Size | Returns the size of template. |
MeasureText(Size, String, TreeGridColumn, Object, GridQueryBounds)
Measures the text of the specified column when the column sizing is SizeToCells or Auto.
Declaration
protected virtual Size MeasureText(Size rectangle, string displayText, TreeGridColumn column, object record, GridQueryBounds queryBounds)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Size | rectangle | The corresponding display rectangle to measure the text. |
System.String | displayText | The displayText to measure. |
TreeGridColumn | column | The corresponding column to measure the text. |
System.Object | record | The corresponding record to measure the text. |
GridQueryBounds | queryBounds | Indicates whether the text is measured based on the height or width of the cell. |
Returns
Type | Description |
---|---|
System.Windows.Size | Returns the size of text. |
OnTreeColumnPropertyChanged(TreeGridColumn, String)
Invoked when the TreeGridColumn property value changes.
Declaration
protected virtual void OnTreeColumnPropertyChanged(TreeGridColumn column, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column on which the property value changes. |
System.String | propertyName | The name of property that value has been changed. |
Refresh()
Refreshes column widths when the ColumnSizer property value changes at SfTreeGrid or TreeGridColumn level.
Declaration
public void Refresh()
Refresh(Double)
Refreshes the column width when the ColumnSizer property value changes at SfTreeGrid or TreeGridColumn level.
Declaration
protected virtual void Refresh(double viewPortWidth)
Parameters
Type | Name | Description |
---|---|---|
System.Double | viewPortWidth | The available width to refresh the column width. |
SetColumnWidth(TreeGridColumn, Double)
Sets the width for the specified column based on MinimumWidth and MaximumWidth property value changes.
Declaration
public virtual double SetColumnWidth(TreeGridColumn column, double Width)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to set the width. |
System.Double | Width | The corresponding width to set. |
Returns
Type | Description |
---|---|
System.Double | Returns the corresponding width for the specified column. |
SetNoneWidth(TreeGridColumn, Double)
Sets the width for the specified column based on None column sizer.
Declaration
protected virtual double SetNoneWidth(TreeGridColumn column, double width)
Parameters
Type | Name | Description |
---|---|---|
TreeGridColumn | column | The corresponding column to set None width. |
System.Double | width | The width to set as None width. |
Returns
Type | Description |
---|---|
System.Double | Returns the None width for the specified column. |
SetStarWidth(Double, IEnumerable<TreeGridColumn>)
Sets the column width based on Star column sizer.
Declaration
protected virtual void SetStarWidth(double remainingColumnWidth, IEnumerable<TreeGridColumn> remainingColumns)
Parameters
Type | Name | Description |
---|---|---|
System.Double | remainingColumnWidth | The available width to adjust the column based on Star column sizer. |
System.Collections.Generic.IEnumerable<TreeGridColumn> | remainingColumns | The collection columns that need to be set star width. |
Remarks
Override this method to customize the Star width calculation in SfTreeGrid.