# Frame

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-frame/

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

```rust
struct Frame
```

A content control that navigates between pages of the WinUI model (WinUI's `Frame`): it shows a
[`FramePage`](/docs/0.5.0/api/ferroui-controls/struct-framepage/) of the type of a navigation and keeps a journal of the pages it showed (the back
and the forward stack) and a cache of pages (`CacheSize`, `FramePage::navigation_cache_mode`).

A navigation is synchronous: `navigate`, `go_back` and `go_forward` raise `Navigating`, which
can cancel it, call the callbacks of the old and the new page, raise `Navigated`, and return; a
navigation requested by one of those handlers while the frame navigates is ignored. The type
of a page is a [`PageType`](/docs/0.5.0/api/ferroui-controls/struct-pagetype/) (`PageType::of::<MyPage>()`, WinUI's `TypeName`); a page is created
by the page factory registered for its type (`register_page_factory`) or by the default
constructor the page type carries. The upstream pages (`Page`, `NavigationPage`) are another model;
docs/porting/winui-controls.md, section 7, compares them.

The WinUI theme has the template (WinUI's `Frame` style of `generic.xaml`); the Fluent and Simple
themes have none. Missing (docs/porting/winui-controls.md, section 10.4): the navigation
transitions (`ContentTransitions`, the `NavigationTransitionInfo` of `Navigate`),
`GetNavigationState` and `SetNavigationState`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L52)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`can_go_back_property`](#function-can_go_back_property)
- [`can_go_forward_property`](#function-can_go_forward_property)
- [`back_stack_depth_property`](#function-back_stack_depth_property)
- [`source_page_type_property`](#function-source_page_type_property)
- [`current_source_page_type_property`](#function-current_source_page_type_property)
- [`cache_size_property`](#function-cache_size_property)
- [`is_navigation_stack_enabled_property`](#function-is_navigation_stack_enabled_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`back_stack`](#function-back_stack)
- [`forward_stack`](#function-forward_stack)
- [`can_go_back`](#function-can_go_back)
- [`can_go_forward`](#function-can_go_forward)
- [`back_stack_depth`](#function-back_stack_depth)
- [`source_page_type`](#function-source_page_type)
- [`current_source_page_type`](#function-current_source_page_type)
- [`cache_size`](#function-cache_size)
- [`is_navigation_stack_enabled`](#function-is_navigation_stack_enabled)
- [`set_is_navigation_stack_enabled`](#function-set_is_navigation_stack_enabled)
- [`current_page`](#function-current_page)
- [`set_cache_size`](#function-set_cache_size)
- [`set_source_page_type`](#function-set_source_page_type)
- [`register_page_factory`](#function-register_page_factory)
- [`unregister_page_factory`](#function-unregister_page_factory)
- [`navigate`](#function-navigate)
- [`navigate_to_type`](#function-navigate_to_type)
- [`go_back`](#function-go_back)
- [`go_forward`](#function-go_forward)
- [`navigating`](#function-navigating)
- [`navigated`](#function-navigated)
- [`navigation_stopped`](#function-navigation_stopped)
- [`navigation_failed`](#function-navigation_failed)

<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/frame.rs#L74)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L74)

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

### can_go_back_property

```rust
fn can_go_back_property() -> &'static DirectProperty<Frame, bool>
```

Defines the `CanGoBack` property: whether the back stack has an entry (read-only).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### can_go_forward_property

```rust
fn can_go_forward_property() -> &'static DirectProperty<Frame, bool>
```

Defines the `CanGoForward` property: whether the forward stack has an entry (read-only).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### back_stack_depth_property

```rust
fn back_stack_depth_property() -> &'static DirectProperty<Frame, i32>
```

Defines the `BackStackDepth` property: the number of entries of the back stack (read-only).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### source_page_type_property

```rust
fn source_page_type_property() -> &'static DirectProperty<Frame, Option<PageType>>
```

Defines the `SourcePageType` property: the type of the page of the last navigation; setting
it navigates to a page of the type. An invalid value is logged and ignored (WinUI's setter
fails with the error of `Navigate`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### current_source_page_type_property

```rust
fn current_source_page_type_property() -> &'static DirectProperty<Frame, Option<PageType>>
```

Defines the `CurrentSourcePageType` property: the type of the page the frame shows (read-only).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### cache_size_property

```rust
fn cache_size_property() -> &'static DirectProperty<Frame, i32>
```

Defines the `CacheSize` property: the number of pages of the cache mode `Enabled` the frame
keeps, 10 by default. A negative value is coerced to 0 and logged.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### is_navigation_stack_enabled_property

```rust
fn is_navigation_stack_enabled_property() -> &'static StyledProperty<bool>
```

Defines the `IsNavigationStackEnabled` property: whether navigations are recorded in the
journal. `true` by default.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L125)

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

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L192)

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

### new

```rust
fn new() -> Ref<Self>
```

Creates a frame with an empty journal.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L217)

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

### back_stack

```rust
fn back_stack(self: &Self) -> NavigationStack
```

Gets the back stack (live; clones are the same list).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L222)

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

### forward_stack

```rust
fn forward_stack(self: &Self) -> NavigationStack
```

Gets the forward stack (live; clones are the same list).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L227)

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

### can_go_back

```rust
fn can_go_back(self: &Self) -> bool
```

Gets whether the back stack has an entry.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L232)

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

### can_go_forward

```rust
fn can_go_forward(self: &Self) -> bool
```

Gets whether the forward stack has an entry.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L237)

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

### back_stack_depth

```rust
fn back_stack_depth(self: &Self) -> i32
```

Gets the number of entries of the back stack.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L242)

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

### source_page_type

```rust
fn source_page_type(self: &Self) -> Option<PageType>
```

Gets the type of the page of the last navigation recorded in the journal.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L247)

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

### current_source_page_type

```rust
fn current_source_page_type(self: &Self) -> Option<PageType>
```

Gets the type of the page the frame shows, as recorded in the journal.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L252)

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

### cache_size

```rust
fn cache_size(self: &Self) -> i32
```

Gets the number of pages of the cache mode `Enabled` the frame keeps.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L257)

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

### is_navigation_stack_enabled

```rust
fn is_navigation_stack_enabled(self: &Self) -> bool
```

Gets whether navigations are recorded in the journal.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L262)

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

### set_is_navigation_stack_enabled

```rust
fn set_is_navigation_stack_enabled(self: &Self, value: bool)
```

Sets whether navigations are recorded in the journal.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L267)

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

### current_page

```rust
fn current_page(self: &Self) -> Option<Ref<FramePage>>
```

Gets the page the frame shows.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L272)

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

### set_cache_size

```rust
fn set_cache_size(self: &Self, value: i32) -> Result<(), NavigationError>
```

Sets the number of pages of the cache mode `Enabled` the frame keeps, and drops the least
recently shown pages beyond it (`NavigationCache::ChangeTransientCacheSize`). A negative size
is an error and changes nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L279)

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

### set_source_page_type

```rust
fn set_source_page_type(self: &Self, value: Option<PageType>) -> Result<bool, NavigationError>
```

Navigates to a page of `value` unless the frame shows a page of it already. `None` is an
error, as in WinUI's `Navigate`. Rust callers get the error; the property setter logs it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L308)

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

### register_page_factory

```rust
fn register_page_factory(self: &Self, source_page_type: impl Into<PageType>, factory: Rc<PageFactory>) -> Result<(), NavigationError>
```

Registers how the frame creates the pages of `source_page_type`, in place of the default
constructor of the type. Pages already in the cache stay there.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L326)

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

### unregister_page_factory

```rust
fn unregister_page_factory(self: &Self, source_page_type: impl Into<PageType>) -> bool
```

Removes the page factory of `source_page_type`; returns whether there was one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L339)

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

### navigate

```rust
fn navigate(self: &Self, source_page_type: impl Into<PageType>, parameter: Option<BoxedValue>) -> Result<bool, NavigationError>
```

Navigates to a page of `source_page_type` with `parameter` (WinUI's `Navigate`), for
example `frame.navigate(PageType::of::<SettingsPage>(), None)`.

`Ok(true)` when the request was taken, also when a handler cancelled it, as WinUI's
`Navigate` returns; `Ok(false)` for a request made during a navigation and for a failure a
`NavigationFailed` handler handled; the error of a failure no handler handled.

A `&'static TypeInfo` converts to a `PageType` that creates the page by reflection, as
before 0.5; that form is deprecated (`PageType::from_type_info`) and removed in #625.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L353)

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

### navigate_to_type

```rust
fn navigate_to_type(self: &Self, source_page_type: impl Into<PageType>, parameter: Option<BoxedValue>, options: &FrameNavigationOptions) -> Result<bool, NavigationError>
```

Navigates to a page of `source_page_type` with `parameter` and `options` (WinUI's
`NavigateToType`); returns as `navigate`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L359)

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

### go_back

```rust
fn go_back(self: &Self) -> Result<(), NavigationError>
```

Navigates to the newest entry of the back stack (WinUI's `GoBack`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L376)

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

### go_forward

```rust
fn go_forward(self: &Self) -> Result<(), NavigationError>
```

Navigates to the newest entry of the forward stack (WinUI's `GoForward`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L391)

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

### navigating

```rust
fn navigating(self: &Self, handler: impl Fn(&NavigatingCancelEventArgs) -> () + 'static) -> Subscription
```

Adds a handler of `Navigating`. Dropping the returned guard removes the handler;
`Subscription::detach` keeps it for the life of the frame.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L639)

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

### navigated

```rust
fn navigated(self: &Self, handler: impl Fn(&NavigationEventArgs) -> () + 'static) -> Subscription
```

Adds a handler of `Navigated`. Dropping the returned guard removes the handler;
`Subscription::detach` keeps it for the life of the frame.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L651)

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

### navigation_stopped

```rust
fn navigation_stopped(self: &Self, handler: impl Fn(&NavigationEventArgs) -> () + 'static) -> Subscription
```

Adds a handler of `NavigationStopped` (a cancelled navigation). Dropping the returned guard
removes the handler; `Subscription::detach` keeps it for the life of the frame.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L663)

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

### navigation_failed

```rust
fn navigation_failed(self: &Self, handler: impl Fn(&NavigationFailedEventArgs) -> () + 'static) -> Subscription
```

Adds a handler of `NavigationFailed`. Dropping the returned guard removes the handler;
`Subscription::detach` keeps it for the life of the frame.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/frame.rs#L675)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`ContentControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- `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`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Frame>`](/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/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`ContentControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)

## Availability

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