# ControlAutomationPeer

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/automation/peers/struct-controlautomationpeer/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct ControlAutomationPeer
```

An automation peer which represents a [`Control`](/docs/0.5.0/api/ferroui-controls/struct-control/).

The peer does not keep its control alive (the control owns the peer); see
`owner`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L20)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`get_children_core`](#function-get_children_core)
- [`get_visual_parent`](#function-get_visual_parent)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`owner`](#function-owner)
- [`try_owner`](#function-try_owner)
- [`get_or_create`](#function-get_or_create)
- [`create_peer_for_element`](#function-create_peer_for_element)
- [`from_element`](#function-from_element)
- [`invalidate_children`](#function-invalidate_children)
- [`invalidate_parent`](#function-invalidate_parent)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L29)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<ControlAutomationPeer>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L29)

<a id="function-get_children_core"></a>

### get_children_core

```rust
fn get_children_core(self: &Self) -> Option<Vec<Ref<AutomationPeer>>>
```

Gets the child automation peers of the peer, or `None` if it has
none. The default implementation returns the peers of the visible
visual children of the owner.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L29)

<a id="function-get_visual_parent"></a>

### get_visual_parent

```rust
fn get_visual_parent(self: &Self) -> Option<Ref<Visual>>
```

Gets the visual the peer of which is the parent of this peer
(not for use outside the framework).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L29)

<a id="function-construct"></a>

### construct

```rust
fn construct(owner: &Control) -> Self
```

Creates the class data of a peer of `owner`; see
`ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L325)

<a id="function-new"></a>

### new

```rust
fn new(owner: &Control) -> Ref<Self>
```

Initializes a new peer of `owner`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L337)

<a id="function-owner"></a>

### owner

```rust
fn owner(self: &Self) -> Ref<Control>
```

Gets the owning control.

A control owns its peer, so the peer holds the control weakly.
## Panics

Panics if the control no longer exists: a peer must not be used
after its control has been released (code that keeps a peer beyond
the life of the tree keeps the control with it, or asks
`try_owner`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L351)

<a id="function-try_owner"></a>

### try_owner

```rust
fn try_owner(self: &Self) -> Option<Ref<Control>>
```

Gets the owning control, or `None` if it no longer exists.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L356)

<a id="function-get_or_create"></a>

### get_or_create

```rust
fn get_or_create(self: &Self, element: &Control) -> Ref<AutomationPeer>
```

Gets or creates an automation peer for a control: this peer for its
owner, the peer of `element` otherwise.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L362)

<a id="function-create_peer_for_element"></a>

### create_peer_for_element

```rust
fn create_peer_for_element(element: &Control) -> Ref<AutomationPeer>
```

Gets an existing automation peer of a control, or creates a new
one if it does not yet exist.

Despite the name (which comes from the analogous WPF API), this
method does not create a new peer if one already exists: instead it
returns the existing peer.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L375)

<a id="function-from_element"></a>

### from_element

```rust
fn from_element(element: &Control) -> Option<Ref<AutomationPeer>>
```

Gets an existing automation peer of a control, or `None` if it does
not yet exist.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L381)

<a id="function-invalidate_children"></a>

### invalidate_children

```rust
fn invalidate_children(self: &Self)
```

Invalidates the peer's children and causes a re-read from
`get_children_core`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L387)

<a id="function-invalidate_parent"></a>

### invalidate_parent

```rust
fn invalidate_parent(self: &Self)
```

Invalidates the peer's parent.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/control_automation_peer.rs#L393)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`AutomationPeerImplExt`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-automationpeerimplext/)
- [`ControlAutomationPeerImplExt`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-controlautomationpeerimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<ControlAutomationPeer>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`ControlAutomationPeerImpl`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-controlautomationpeerimpl/)
- [`AutomationPeerImpl`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-automationpeerimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
