> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/code/controls/frameworkelement.md).

# FrameworkElement

## Introduction

FrameworkElement is the base class for all Gum Forms controls. Gum Forms controls are a collection of controls which often are used to build up UI such as [Button](/gum/code/controls/button.md), [ListBox](/gum/code/controls/listbox.md), [Label](/gum/code/controls/label.md), and [TextBox](/gum/code/controls/textbox.md). FrameworkElement provides much of the common functionality across all controls.

The FrameworkElement class is usually not directly instantiated. Rather, derived types such as Button and TextBox are created. FrameworkElement can also be used as a base class for custom controls.

## Visual

FrameworkElements have a Visual property which is of type InteractiveGue. This Visual property is used to customize the appearance of the FrameworkElement. Common types of properties that can be modified through the Visual property include:

* Position such as `X`, `XUnits`, and `XOrigin`
* Size such as `Width`, `WidthUnits`, `MinWidth`, and `MaxWidth`
* Properties controlling how children are positioned such as `ChildrenLayout`, `AutoGridHorizontalCells`, and `StackSpacing`
* Shortcut methods for quick positioning and sizing such as `Anchor` and `Dock`

For example, to change the Width of a Button, the following code might be used.

```csharp
// Initialize
Button.Visual.Width = 100;
```

FrameworkElements offer a few common shortcut properties and methods for commonly-accessed properties. These shortcut methods are effectively the same thing as setting properties or calling methods on the Visual object. These properties are:

* X
* Y
* Width
* Height
* Anchor
* Dock

For example, the following two blocks of code are identical:

```csharp
// Initialize
// Properties can be assigned through shortcuts...
Label.Dock(Dock.Left);
Label.X = 10;
// ...or they can be assigned directly on the Visual
Label.Visual.Dock(Dock.Left);
Label.Visual.X = 10;
```

Some properties, such as WidthUnits, must be directly assigned on the Visual object.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/gum/code/controls/frameworkelement.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
