Class Panel
A Panel is a GraphObject that holds other GraphObjects as its elements. A Panel is responsible for sizing and positioning its elements. The elements of a panel are drawn in the order in which they appear in the Elements collection.
The Part class inherits from Panel; Part in turn is the base class of Node and Link.
Namespace: Northwoods.Go
Assembly: Northwoods.GoDiagram.Avalonia.dll
Syntax
public class Panel : GraphObject, IHasContextMenu, IHasToolTip
Remarks
Every Panel has a Type and establishes its own coordinate system. The type of a Panel determines how it will size and arrange its elements:
- PanelLayoutPosition is used to arrange elements based on their absolute positions within the Panel's local coordinate system.
- PanelLayoutVertical and PanelLayoutHorizontal are used to create linear "stacks" of elements.
- PanelLayoutAuto is used to size the main element to fit around other elements in the Panel -- this creates borders.
- PanelLayoutSpot is used to arrange elements based on the Spot properties Alignment and AlignmentFocus, relative to a main element of the panel. Spot panels can align relative to other elements by using AlignmentFocusName.
- PanelLayoutTable is used to arrange elements into rows and columns, typically employing the different elements' Row, RowSpan, Column, and ColumnSpan properties. This Panel type also makes use of RowDefinition/ColumnDefinition.
- PanelLayoutTableRow and PanelLayoutTableColumn can only be used immediately within a PanelLayoutTable Panel to organize a collection of elements as a row or as a column in a table.
- PanelLayoutViewbox is used to automatically resize a single element to fit inside the panel's available area.
- PanelLayoutGrid is not used to house typical elements, but is used only to draw regular patterns of lines. The elements must be Shapes used to describe the repeating lines.
- PanelLayoutLink is only used by Link parts and Link Adornments.
- PanelLayoutGraduated is used to draw regular tick marks and text along the main Shape element.
Using the constructor, the argument can be used to declare the Panel type:
new Panel(PanelType.Horizontal) { ... }
// Full example:
new Panel(PanelType.Horizontal) {
Width = 60, Height = 60 // panel properties
}
.Add(
new Shape("Rectangle") { Stroke = "lime" },
new TextBlock("Some Text")
) // end of panel definition
For an overview of most Panel types, please read the Introduction page on Panels.
PanelLayoutVertical and PanelLayoutHorizontal panels are frequently used to position two or more GraphObjects vertically above each other or horizontally next to each other. Use the Alignment or Stretch properties on the individual elements to control their position and size. Set IsOpposite to true if you want the elements arranged from right-to-left in Horizontal Panels or from bottom-to-top in Vertical Panels.
PanelLayoutSpot and PanelLayoutAuto panels have a "main" element, signified by the Panel's first element with IsPanelMain set to true. If there is no such element, it uses the first element as the "main" one. Use the Alignment property to position elements with respect to the main element. Use the AlignmentFocus property to further specify the position within Spot Panels. "Spot" and "Auto" Panels should have two or more elements in them.
In PanelLayoutTable panels you will want to set the Row and Column properties on each element. The Alignment and Stretch properties are also useful when an element's table cell is larger than that element.
Please read the Introduction page on Table Panels for more examples and explanation.
PanelLayoutTableRow and PanelLayoutTableColumn panels can only be used as elements within a PanelLayoutTable Panel. They are typically only used in item templates, e.g. for automatically creating rows in a Table Panel based on model data provided in an ItemList. You will still need to specify properties on the individual elements within a TableRow or TableColumn as if they were immediate elements of the containing Table panel.
For an example that uses TableRow Panels, see Records sample.
PanelLayoutGrid panels are often used for the Diagram's Grid.
myDiagram.Grid =
new Panel(PanelType.Grid) { GridCellSize = new Size(40, 40) }
.Add(
new Shape("LineH") { Stroke = "lightgray" },
new Shape("LineV") { Stroke = "lightgray" }
);
Or to get a green bar effect:
myDiagram.Grid =
new Panel(PanelType.Grid) { GridCellSize = new Size(100, 100) }
.Add(new Shape("BarH") { Fill = "lightgreen", Height = 50 });
But Grid Panels can also be stand alone objects:
new Node(PanelType.Grid) {
GridCellSize = new Size(6, 6), Width = 60, Height = 60
}
.Add(
new Shape("LineH") { Stroke = "gray" },
new Shape("LineV") { Stroke = "gray" }
)
A Grid Panel's elements do not participate in object picking.
Please read the Introduction page on Grid Patterns for more examples and explanation.
PanelLayoutGraduated panels, like Spot and Auto Panels have a "main" element. The other elements within a Graduated Panel are used to define ticks and labels to draw along the main shape's path.
new Part(PanelType.Graduated)
.Add(
new Shape { GeometryString = "M0 0 H400 },
new Shape { GeometryString = "M0 0 V10" },
// offset to display below ticks
new TextBlock { SegmentOffset = new Point(0, 12) }
);
Only the main shape of a Graduated Panel participates in object picking, but a Background
can be set if the entire panel needs to be pickable.
You cannot set or bind the ItemList of a Graduated Panel.
Events on the tick Shapes and TextBlock labels of a Graduated Panel will be ignored.
Graduated Panel TextBlock labels cannot be edited.
Rotating the main shape will not rotate the ticks, just as rotating a Spot Panel's main element won't rotate its children. Rotation should generally be done at the Panel level. Another similarity to Spot Panels is that resizing of a Graduated Panel should generally be done on the main shape.
Please read the Introduction page on Graduated Panels for more examples and explanation.
Changing and accessing elements of a Panel
You can change the collection of Elements by calling Add(params GraphObject[]), InsertAt(int, GraphObject), Remove(GraphObject), or RemoveAt(int). You can get direct access to a particular element by calling Elt(int).
Alternatively you can control the number and order of elements that are copies of an item template by setting or binding the ItemList property. This is discussed below.
You can search the visual tree of a Panel for GraphObjects that given a Name using FindElement(string).
Panel Size and Appearance
Panels typically compute their own size based on their elements and Panel Type, but can also be sized by setting DesiredSize, MinSize, and MaxSize. Setting an explicit size on a Panel may cause nested elements of that panel to size themselves differently, especially in the cases of nested elements having a Stretch value or TextBlock's having word wrap.
Panels have no visual components of their own unless a Background is specified or separators are specified either as defaults for the whole Table Panel or on individual RowDefinition/ColumnDefinitions. Panels can specify Padding, to make the Panel larger including its background. Setting a padding when the Panel is constrained in size will reduce the total area that it has to arrange its elements. Setting a Margin will not do this -- instead the Panel will expand in size.
In addition to the GraphObject properties on elements that are only used by certain types of panels, several Panel properties only apply to specific Panel types.
- Panels of Type PanelLayoutTable use the RowCount, RowSizing, ColumnCount, ColumnSizing, LeftIndex, TopIndex, and all of the "default" separator properties.
- Panels of Type PanelLayoutTableRow and PanelLayoutTableColumn do not act like regular GraphObjects, instead they are only to be used immediately within a PanelLayoutTable. They are pass-through containers that hold elements for their parent table, and ignore their own scale and angle.
- Panels of Type PanelLayoutGrid use the GridCellSize and GridOrigin properties.
- Panels of Type PanelLayoutViewbox use the ViewboxStretch property.
- Panels of Type PanelLayoutGraduated use the GraduatedMin, GraduatedMax, GraduatedTickUnit, and GraduatedTickBase properties.
For live examples of all Panel types, see the Introduction page on Panels.
Data Binding
Panels also provide fundamental support for data binding. When a diagram gets a new model or when a diagram's model is augmented with additional data, the diagram automatically creates a new Node or Link whose Data property refers to the corresponding node data or link data object.
For more discussion of data binding, please read the Introduction page on Models and Data Binding.
Panels provide support for automatically creating elements within the Panel based on items in a collection. This is achieved by setting or binding the ItemList property, which acts in a manner similar to the NodeDataSource property. You can supply an ItemTemplate, which must itself be a simple Panel, which is copied to create the element in this container Panel corresponding to an item in the ItemList. This property is analogous to the NodeTemplate property, although for the diagram the template must be a Node, Group, or simple Part.
Much like the NodeTemplateMap, Panel's ItemTemplateMap supports having multiple templates, so that the actual structure of the element created for a data item can be chosen dynamically. Just as the NodeCategoryProperty determines which template in the NodeTemplateMap is copied to create a Node, the ItemCategoryProperty names the data property whose value chooses the Panel in the ItemTemplateMap to copy for the item.
When binding the ItemList property, it is commonplace to customize the model's copying processes, by supplying a custom CopyNodeDataFunction.
For more discussion and examples of item lists, please read the Introduction page on Item Lists.
Constructors
Panel()
Constructs an empty Panel of the given Type. Default type is PanelLayoutPosition.
Declaration
public Panel()
Remarks
The default Panel type is PanelLayoutPosition.
Panel(PanelLayout)
Constructs an empty Panel of the given PanelLayout Type. The default type is PanelLayoutPosition. The panel type must be a PanelLayout instance.
Declaration
public Panel(PanelLayout type)
Parameters
Type | Name | Description |
---|---|---|
PanelLayout | type | if null, the default Panel type is PanelLayoutPosition. |
Panel(string)
Constructs an empty Panel of the given PanelLayout Type. The panel type can be a string describing one of the built-in PanelLayout types, available under the PanelType static class.
Declaration
public Panel(string type)
Parameters
Type | Name | Description |
---|---|---|
string | type | if the empty string, the default Panel type is PanelLayoutPosition. |
Properties
AlignmentFocusName
For Panels which are elements of Spot Panels: Gets or sets the name of this Panel's element that should be used as the alignment object instead of this Panel.
Declaration
public string AlignmentFocusName { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
This allows Spot Panels to align objects that are nested in the element tree of its own elements.
ColumnCount
For Table Panels: This read-only property returns the number of columns.
Declaration
public int ColumnCount { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This value is only valid after the Panel has been measured.
ColumnSizing
For Table Panels: Gets or sets how this Panel's columns deal with extra space.
Declaration
public Sizing ColumnSizing { get; set; }
Property Value
Type | Description |
---|---|
Sizing |
Remarks
Valid values are ProportionalExtra and None. The default is ProportionalExtra.
See Also
Data
Gets or sets the optional model data to which this panel is data-bound.
Declaration
public object Data { get; set; }
Property Value
Type | Description |
---|---|
object |
Remarks
The data must be an object if this is a Part. The data can be any value if this is a Panel created for an item in an list that was data-bound by the ItemList property. The default value is null.
Setting it to a new value automatically calls UpdateTargetBindings(string) in order to assign new values to all of the data-bound GraphObject properties.
Once you set this property you cannot add, remove, or modify any data bindings on any of the GraphObjects in the visual tree of this Panel, including on this panel itself.
You should not modify this property on a Part that is created automatically to represent model data, nor on a Panel that is created automatically for a data item in the containing Panel's ItemList. Call RemoveNodeData(TNodeData) and AddNodeData(TNodeData) if you want to replace this Part with another one, or call RemoveListItem(IList, int) and InsertListItem(IList, int, object) if you want to replace this Panel with another one.
Although you might not be able to replace this data value if this Part was created automatically by the Diagram, you can still modify that data object's properties. Call the appropriate Model method for changing properties that affect the structure of the diagram. Call Set(object, string, object) for changing other properties that may be the sources of Bindings on GraphObject properties that are in the visual tree of this panel/part.
DefaultAlignment
Gets or sets the default alignment spot of this Panel, used as the alignment for an element when its Alignment value is Default.
Declaration
public Spot DefaultAlignment { get; set; }
Property Value
Type | Description |
---|---|
Spot |
Remarks
The default value is Default, which is interpreted by the Panel in whatever manner seems reasonable, depending on the Panel type.
DefaultColumnSeparatorDashArray
For Table Panels: Gets or sets the default dash array for a column's separator.
Declaration
public float[] DefaultColumnSeparatorDashArray { get; set; }
Property Value
Type | Description |
---|---|
float[] |
Remarks
SeparatorStrokeWidth can override this default value.
Must be an array of positive numbers and zeroes, or else null to indicate a solid line.
For example, the array [5, 10] would create dashes of 5 pixels and spaces of 10 pixels.
Setting an array with all zeroes will set the value to null.
Default is null.
See Also
DefaultColumnSeparatorStroke
For Table Panels: Gets or sets the default stroke (color) for columns provided a given column has a nonzero SeparatorStrokeWidth.
Declaration
public Brush DefaultColumnSeparatorStroke { get; set; }
Property Value
Type | Description |
---|---|
Brush |
Remarks
SeparatorDashArray can override this default value. The default value is null -- no line is drawn.
See Also
DefaultColumnSeparatorStrokeWidth
For Table Panels: Gets or sets the default stroke width for a column's separator.
Declaration
public double DefaultColumnSeparatorStrokeWidth { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
SeparatorStrokeWidth can override this default value. The default value is 1. Any new value must be a real, non-negative number.
See Also
DefaultRowSeparatorDashArray
For Table Panels: Gets or sets the default dash array for a row's separator.
Declaration
public float[] DefaultRowSeparatorDashArray { get; set; }
Property Value
Type | Description |
---|---|
float[] |
Remarks
SeparatorDashArray can override this default value.
Must be an array of positive numbers and zeroes, or else null to indicate a solid line.
For example, the array [5, 10] would create dashes of 5 pixels and spaces of 10 pixels.
Setting an array with all zeroes will set the value to null.
Default is null.
See Also
DefaultRowSeparatorStroke
For Table Panels: Gets or sets the default stroke (color) for rows provided a given row has a nonzero SeparatorStrokeWidth.
Declaration
public Brush DefaultRowSeparatorStroke { get; set; }
Property Value
Type | Description |
---|---|
Brush |
Remarks
SeparatorStroke can override this default value. The default value is null -- no line is drawn.
See Also
DefaultRowSeparatorStrokeWidth
For Table Panels: Gets or sets the default stroke width for a row's separator.
Declaration
public double DefaultRowSeparatorStrokeWidth { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
SeparatorStrokeWidth can override this default value. The default value is 1. Any new value must be a real, non-negative number.
See Also
DefaultSeparatorPadding
For Table Panels: Gets or sets the additional padding for rows and columns.
Declaration
public Margin DefaultSeparatorPadding { get; set; }
Property Value
Type | Description |
---|---|
Margin |
Remarks
Padding is applied both before and after a row or column's contents.
See Also
DefaultStretch
Gets or sets the default stretch of this Panel, used as the stretch for an element when its Stretch value is Default.
Declaration
public Stretch DefaultStretch { get; set; }
Property Value
Type | Description |
---|---|
Stretch |
Remarks
Elements
This read-only property returns an iterator over the collection of the GraphObjects that this panel manages.
Declaration
public IEnumerable<GraphObject> Elements { get; }
Property Value
Type | Description |
---|---|
IEnumerable<GraphObject> |
Remarks
You can change the collection by calling Add(params GraphObject[]), InsertAt(int, GraphObject), Remove(GraphObject), or RemoveAt(int).
You can also get direct access to individual elements by calling Elt(int).
GraduatedMax
For Graduated Panels: Gets or sets the maximum value represented.
Declaration
public double GraduatedMax { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Must be greater than GraduatedMin. The default is 100.
GraduatedMin
For Graduated Panels: Gets or sets the minimum value represented.
Declaration
public double GraduatedMin { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Must be less than GraduatedMax. The default is 0.
GraduatedRange
For Graduated Panels: This read-only property returns the range of values represented by the Panel.
Declaration
public double GraduatedRange { get; }
Property Value
Type | Description |
---|---|
double |
Remarks
For example, a GraduatedMin of 25 and GraduatedMax of 75 would return 50.
GraduatedTickBase
For Graduated Panels: Gets or sets the base value which is marked with a tick.
Declaration
public double GraduatedTickBase { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
The default is 0.
GraduatedTickUnit
For Graduated Panels: Gets or sets the difference between two consecutive values marked by ticks.
Declaration
public double GraduatedTickUnit { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Must be positive. The default is 10.
GridCellSize
For Grid Panels: Gets or sets the distance between lines.
Declaration
public Size GridCellSize { get; set; }
Property Value
Type | Description |
---|---|
Size |
Remarks
The units are in local coordinates. The default is 10x10. Any new width or height must be a positive real number.
GridOrigin
For Grid Panels: Gets or sets an origin point for the grid cells.
Declaration
public Point GridOrigin { get; set; }
Property Value
Type | Description |
---|---|
Point |
Remarks
The units are in local coordinates. The default is (0,0). Any new value must use real numbers.
IsClipping
For Spot Panels: Gets or sets whether this Panel's main element clips instead of fills.
Declaration
public bool IsClipping { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The main element will not paint its stroke, if it has any. This assumes that the main element is a Shape.
For Groups: Gets or sets whether this Group's Placeholder clips its member nodes. For compatibility, if the Group is a PanelLayoutSpot Panel, it will not clip its members.
When this property is true
, the Spot panel will size itself to be the intersection of the main element bounds and
all other elements' bounds, rather than the union of these bounds.
IsEnabled
Gets or sets whether this Panel or any GraphObject inside the panel actually responds to user click events.
Declaration
public bool IsEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
May be used as a Binding target. See how this property is used in Buttons.cs.
This property does not have any effect on picking ("hit-testing") -- that behavior is implemented by the Pickable property. When this property is false, non-click events may still occur on this panel or on objects within this panel. This property is normally only used for Panels that are IsActionable.
Call IsEnabledElement() to decide whether a particular object can be clicked.
See Also
IsOpposite
For Horizontal and Vertical Panels: gets or sets whether this Panel arranges its contents from the typical side (left and top, respectively), or the opposite side (right and bottom, respectively).
Declaration
public bool IsOpposite { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The default value is false.
ItemCategoryProperty
Gets or sets the name of the item data property that returns a string describing that data's category.
Declaration
public string ItemCategoryProperty { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
The default value is the name "Category".
This is used to distinguish between different kinds of items in the ItemList.
The name must not be null. If the value is an empty string, the category is assumed to be an empty string, the default category name, for all item data objects. You must not change this property when the ItemList already has a value.
ItemIndex
Gets the index of this Panel's data if it was created to represent an item in its containing Panel's ItemList.
Declaration
public int ItemIndex { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The default value is double.NaN.
This is only set internally by code such as RebuildItemElements() or InsertListItem(IList, int, object) when building or shifting a Panel representing items in the Panel whose ItemList was set or bound to a list of values.
This property can be used in data bindings within the item template to produce values that depend on its position in the item list. For example:
new Panel {
...,
ItemTemplate =
new Panel() // the item Panel
// set Panel.Background to a color based on the Panel.ItemIndex
.Bind(
new Binding("Background", "ItemIndex",
// using this conversion function
(i, _) => { return ((int)i % 2 == 0) ? "lightgreen" : "lightyellow"; })
// bound to this Panel itself, not to the Panel.Data item
.OfElement()
)
.Add(
new TextBlock().Bind("Text") // a trivial item template, just showing some text
)
}
.Bind("ItemList", "SomeProperty")
The main element of a Spot or Auto or Link Panel, or the first TableRow or TableColumn element of a Table Panel whose IsPanelMain property is true, will not have this property set to a number, because it will not have been created by RebuildItemElements().
ItemList
Gets or sets a list of values or objects, each of which will be represented by a Panel as elements in this Panel.
Declaration
public IList ItemList { get; set; }
Property Value
Type | Description |
---|---|
IList |
Remarks
Replacing this list results all of this panel's child elements being replaced with a copy of the Panel found in ItemTemplateMap for each particular item in the list.
Because the software does not receive any notifications when a list is modified, any insertions or removals or replacements of data in the list will not be noticed unless you call InsertListItem(IList, int, object) or RemoveListItem(IList, int). You may also reset this property to its current value (the modified list) or call UpdateTargetBindings(string), if there is a Binding whose target is this property.
When binding this property, it is commonplace to customize the model's copying processes. You can supply a custom CopyNodeDataFunction and perhaps a CopyLinkDataFunction.
Any object that is in this list must only appear once and must not appear in any other ItemLists. Use FindItemPanelForData(object) to find the data-bound Panel created for an object in this panel's item list.
Non-object values in an item list may appear multiple times. An item list may be shared by multiple Panels.
Item lists should not be used with Grid Panels or Graduated Panels as they may not have nested Panels.
ItemTemplate
Declaration
public Panel ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
Panel |
Remarks
Setting this property just modifies the ItemTemplateMap by replacing the entry named with the empty string. Any new value must be a Panel but not a Part. By default this property is null.
Copy() when copying a panel will share the ItemTemplateMap between the original panel and the copied panel.
ItemTemplateMap
Gets or sets a dictionary mapping template names to Panels.
Declaration
public IDictionary<string, Panel> ItemTemplateMap { get; set; }
Property Value
Type | Description |
---|---|
IDictionary<string, Panel> |
Remarks
One of these Panels is copied for each item data that is in the ItemList. Replacing this map will automatically rebuild all of the elements in this Panel.
By default this property is null. All values in the dictionary must be Panels but not Parts.
If you modify this dictionary, by replacing a Panel or by adding or removing a map entry, you need to explicitly call RebuildItemElements() afterwards.
Copy() when copying a panel will share the ItemTemplateMap between the original panel and the copied panel.
LeftIndex
For Table Panels: Gets or sets the first column that this Panel displays.
Declaration
public int LeftIndex { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The default value is 0.
See Also
Padding
Gets or sets the space between this Panel's border and its content.
Declaration
public Margin Padding { get; set; }
Property Value
Type | Description |
---|---|
Margin |
Remarks
Unlike Margin, padding expands the area inside of the Panel's border. If this Panel's size is unconstrained, this will increase the size of the panel. If this Panel's size is constrained, this will decrease the total area for the Panel elements to arrange themselves.
Unlike margin, increases in size due to padding are visually covered by the Background.
Padding cannot contain negative numbers. The default value is a Margin of zero.
See Also
RowCount
For Table Panels: This read-only property returns the number of rows.
Declaration
public int RowCount { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This value is only valid after the Panel has been measured.
RowSizing
For Table Panels: Gets or sets how this Panel's rows deal with extra space.
Declaration
public Sizing RowSizing { get; set; }
Property Value
Type | Description |
---|---|
Sizing |
Remarks
Valid values are ProportionalExtra and None. The default is ProportionalExtra.
See Also
TopIndex
For Table Panels: Gets or sets the first row that this Panel displays.
Declaration
public int TopIndex { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The default value is 0.
See Also
Type
Gets or sets the type of the Panel, which controls how the Panel's elements are measured and arranged.
Declaration
public PanelLayout Type { get; set; }
Property Value
Type | Description |
---|---|
PanelLayout |
Remarks
The value must be an instance of PanelLayout. The only predefined values are:
- PanelLayoutPosition
- PanelLayoutVertical
- PanelLayoutHorizontal
- PanelLayoutAuto
- PanelLayoutSpot
- PanelLayoutTable
- PanelLayoutViewbox
- PanelLayoutLink (see also Links, which are all Panels of type Link)
- PanelLayoutTableRow
- PanelLayoutTableColumn
- PanelLayoutGrid
- PanelLayoutGraduated
The default value is PanelLayoutPosition.
You must not modify this property once the Panel has been measured or the Panel has been added to another Panel.
ViewboxStretch
For Viewbox Panels: Gets or sets how the panel will resize its content.
Declaration
public ViewboxStretch ViewboxStretch { get; set; }
Property Value
Type | Description |
---|---|
ViewboxStretch |
Remarks
Possible values are Uniform and UniformToFill. The default is Uniform.
Methods
Add(params ColumnDefinition[])
Adds a number of ColumnDefinitions to this Table panel.
Declaration
public Panel Add(params ColumnDefinition[] cols)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition[] | cols | A number of ColumnDefinitions. |
Returns
Type | Description |
---|---|
Panel | this Panel |
Remarks
This method will throw an error if used on a Panel that isn't of Type PanelLayoutTable. If the column already exists in the Table Panel, this method will modify the existing column.
Add(params GraphObject[])
Adds a number of GraphObjects to the end of this Panel's list of elements, visually in front of all of the other elements.
Declaration
public Panel Add(params GraphObject[] elements)
Parameters
Type | Name | Description |
---|---|---|
GraphObject[] | elements | A variable number of GraphObject parameters. |
Returns
Type | Description |
---|---|
Panel | this Panel |
Remarks
If an element to be added is already in this Panel's list of elements, the object is moved to the end of the list. You cannot add a GraphObject to a Panel if that GraphObject is already in a different Panel.
Add(params RowDefinition[])
Adds a number of RowDefinitions to this Table panel.
Declaration
public Panel Add(params RowDefinition[] rows)
Parameters
Type | Name | Description |
---|---|---|
RowDefinition[] | rows | A number of RowDefinitions. |
Returns
Type | Description |
---|---|
Panel | this Panel |
Remarks
This method will throw an error if used on a Panel that isn't of Type PanelLayoutTable. If the row already exists in the Table Panel, this method will modify the existing row.
Add(IEnumerable<GraphObject>)
Adds a number of GraphObjects to the end of this Panel's list of elements, visually in front of all of the other elements.
Declaration
public Panel Add(IEnumerable<GraphObject> elements)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<GraphObject> | elements | An enumerable of GraphObjects. |
Returns
Type | Description |
---|---|
Panel | this Panel |
Remarks
If an element to be added is already in this Panel's list of elements, the object is moved to the end of the list. You cannot add a GraphObject to a Panel if that GraphObject is already in a different Panel.
Copy()
Creates a deep copy of this Panel and returns it.
Declaration
public override GraphObject Copy()
Returns
Type | Description |
---|---|
GraphObject |
Overrides
CopyTemplate(bool)
Make a deep copy of this Panel and allow it to be used as a template.
Declaration
public Panel CopyTemplate(bool freeze = false)
Parameters
Type | Name | Description |
---|---|---|
bool | freeze | whether to freeze the Bindings in the copy; default is false |
Returns
Type | Description |
---|---|
Panel |
Remarks
This makes copies of Bindings, unlike the regular Copy() method. Pass true as the argument in order to freeze the Bindings, allowing it to operate efficiently as a template. A false value (which is the default) allows further additions/modifications of the bindings in the copied panel.
Elt(int)
Returns the GraphObject in this Panel's list of elements at the specified index.
Declaration
public GraphObject Elt(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx |
Returns
Type | Description |
---|---|
GraphObject |
FindColumnForLocalX(double)
For Table Panels: Returns the cell at a given x-coordinate in local coordinates, or -1 if there are no ColumnDefinitions for this Table Panel or if the argument is negative.
Declaration
public int FindColumnForLocalX(double x)
Parameters
Type | Name | Description |
---|---|---|
double | x |
Returns
Type | Description |
---|---|
int | a zero-based integer |
Remarks
Call GetLocalPoint(Point) to convert a Point in document coordinates into a Point in local coordinates.
See Also
FindElement(string)
Search the visual tree starting at this Panel for a GraphObject whose Name is the given name.
Declaration
public virtual GraphObject FindElement(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name to search for, using a case-sensitive string comparison. |
Returns
Type | Description |
---|---|
GraphObject | If no such named element can be found, this returns null. |
Remarks
This does not recurse into the elements inside a Panel that holds elements for an ItemList.
FindItemPanelForData(object)
Declaration
public Panel FindItemPanelForData(object data)
Parameters
Type | Name | Description |
---|---|---|
object | data | must be an Object, not a string or a number or a bool or a function |
Returns
Type | Description |
---|---|
Panel | null if not found |
Remarks
If this returns a Panel, its Data property will be the argument data object, and its containing Panel will be this panel.
FindMainElement()
Return an immediate child element whose IsPanelMain is true, or else just return the first child element.
Declaration
public GraphObject FindMainElement()
Returns
Type | Description |
---|---|
GraphObject | this may return null if there are no child elements |
FindRowForLocalY(double)
For Table Panels: Returns the row at a given y-coordinate in local coordinates, or -1 if there are no RowDefinitions for this Table Panel or if the argument is negative.
Declaration
public int FindRowForLocalY(double y)
Parameters
Type | Name | Description |
---|---|---|
double | y |
Returns
Type | Description |
---|---|
int | a zero-based integer |
Remarks
Call GetLocalPoint(Point) to convert a Point in document coordinates into a Point in local coordinates.
See Also
GetColumnDefinition(int)
For Table Panels: Gets the ColumnDefinition for a particular column.
Declaration
public virtual ColumnDefinition GetColumnDefinition(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | the non-negative zero-based integer column index. |
Returns
Type | Description |
---|---|
ColumnDefinition |
Remarks
If you ask for the definition of a column at or beyond the ColumnCount, it will automatically create one and return it.
If this Panel is not a Table Panel, this method returns null.
GetRowDefinition(int)
For Table Panels: Gets the RowDefinition for a particular row.
Declaration
public virtual RowDefinition GetRowDefinition(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | the non-negative zero-based integer row index. |
Returns
Type | Description |
---|---|
RowDefinition |
Remarks
If you ask for the definition of a row at or beyond the RowCount, it will automatically create one and return it.
If this Panel is not a Table Panel, this method returns null.
GraduatedPointForValue(double)
For Graduated Panels: Returns the point that corresponds with a value, in the panel's coordinates.
Declaration
public Point GraduatedPointForValue(double val)
Parameters
Type | Name | Description |
---|---|---|
double | val | a value between GraduatedMin and GraduatedMax |
Returns
Type | Description |
---|---|
Point |
Remarks
If the value provided is not within the GraduatedMin and GraduatedMax, it will be constrained to within those values.
If this Panel is not a Graduated Panel, this method returns Point(double.NaN, double.NaN).
See Also
GraduatedValueForPoint(Point)
For Graduated Panels: Returns the value that corresponds with the given Point.
Declaration
public double GraduatedValueForPoint(Point pt)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | a Point in the Graduated Panel's coordinates |
Returns
Type | Description |
---|---|
double |
Remarks
The Point must be in the panel's coordinates. The value returned will be in the Graduated Panel's range.
If this Panel is not a Graduated Panel, this method returns double.NaN.
See Also
InsertAt(int, GraphObject)
Adds a GraphObject to the Panel's list of elements at the specified index.
Declaration
public void InsertAt(int index, GraphObject element)
Parameters
Type | Name | Description |
---|---|---|
int | index | |
GraphObject | element | A GraphObject. |
Remarks
If the element to be added is already in this Panel's list of elements, the element is moved to the specified index. You cannot add a GraphObject to a Panel that if that GraphObject is already in a different Panel.
RebuildItemElements()
Create and add new GraphObjects corresponding to and bound to the data in the ItemList, after removing all existing elements from this Panel.
Declaration
public void RebuildItemElements()
Remarks
This method is automatically called when replacing the ItemList value, or when changing the value of ItemTemplate or ItemTemplateMap.
This uses ItemCategoryProperty to determine the category for an item data. That string is used to look up a template in ItemTemplateMap. The resulting template (which is also a Panel) is copied, added to this panel, and its ItemIndex is set to its index in that list. That new child Panel is then data-bound to that list item by setting its Data.
If ItemList is null, this method just removes all elements from this panel. Actually, if this Panel Type is "Spot", "Auto", or "Link", the very first element is always kept by this method. Also, if this Panel type is "Table", and if the first element is a "TableRow" or "TableColumn" Panel whose IsPanelMain property is set to true, that first element will be kept too. That is useful for defining literal TableRow headers in Table panels, when the header information is not kept as the first item in the ItemList.
It is wasteful to call this method after making some model data changes. It is better to call Set(object, string, object), AddListItem(IList, object), InsertListItem(IList, int, object), or RemoveListItem(IList, int), or other model methods. Not only do those methods update efficiently, they also preserve unbound state and support undo/redo.
Remove(GraphObject)
Removes a GraphObject from this Panel's list of elements.
Declaration
public void Remove(GraphObject element)
Parameters
Type | Name | Description |
---|---|---|
GraphObject | element | A GraphObject. |
RemoveAt(int)
Removes an GraphObject from this Panel's list of elements at the specified index.
Declaration
public void RemoveAt(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx |
RemoveColumnDefinition(int)
For Table Panels: Removes the ColumnDefinition for a particular column.
Declaration
public void RemoveColumnDefinition(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | the non-negative zero-based integer row index. |
Remarks
If this Panel is not a Table Panel, this method does nothing.
RemoveRowDefinition(int)
For Table Panels: Removes the RowDefinition for a particular row.
Declaration
public void RemoveRowDefinition(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | the non-negative zero-based integer row index. |
Remarks
If this Panel is not a Table Panel, this method does nothing.
UpdateTargetBindings(string)
Re-evaluate all data bindings on this panel, in order to assign new property values to the GraphObjects in this visual tree based on this object's Data property values.
Declaration
public virtual void UpdateTargetBindings(string srcprop = "")
Parameters
Type | Name | Description |
---|---|---|
string | srcprop | An optional source data property name: when provided, only evaluates those Bindings that use that particular property; when not provided or when it is the empty string, all bindings are evaluated. |
Remarks
It is better to call Set(object, string, object) to modify data properties, because that will both record changes for undo/redo and will update all bindings that may depend on that property.
This method does nothing if Data is null.