Frame
struct · ferroui-controls · v0.5.0
struct Frame
A content control that navigates between pages of the WinUI model (WinUI's Frame): it shows a
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 (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.
Members
TYPEto_refcan_go_back_propertycan_go_forward_propertyback_stack_depth_propertysource_page_type_propertycurrent_source_page_type_propertycache_size_propertyis_navigation_stack_enabled_propertyconstructnewback_stackforward_stackcan_go_backcan_go_forwardback_stack_depthsource_page_typecurrent_source_page_typecache_sizeis_navigation_stack_enabledset_is_navigation_stack_enabledcurrent_pageset_cache_sizeset_source_page_typeregister_page_factoryunregister_page_factorynavigatenavigate_to_typego_backgo_forwardnavigatingnavigatednavigation_stoppednavigation_failed
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<Frame>
Returns a strong reference to this object.
can_go_back_property
fn can_go_back_property() -> &'static DirectProperty<Frame, bool>
Defines the CanGoBack property: whether the back stack has an entry (read-only).
can_go_forward_property
fn can_go_forward_property() -> &'static DirectProperty<Frame, bool>
Defines the CanGoForward property: whether the forward stack has an entry (read-only).
back_stack_depth_property
fn back_stack_depth_property() -> &'static DirectProperty<Frame, i32>
Defines the BackStackDepth property: the number of entries of the back stack (read-only).
source_page_type_property
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).
current_source_page_type_property
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).
cache_size_property
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.
is_navigation_stack_enabled_property
fn is_navigation_stack_enabled_property() -> &'static StyledProperty<bool>
Defines the IsNavigationStackEnabled property: whether navigations are recorded in the
journal. true by default.
construct
fn construct() -> Self
Creates the class data; see ferroui_base::FerroObject::construct.
new
fn new() -> Ref<Self>
Creates a frame with an empty journal.
back_stack
fn back_stack(self: &Self) -> NavigationStack
Gets the back stack (live; clones are the same list).
forward_stack
fn forward_stack(self: &Self) -> NavigationStack
Gets the forward stack (live; clones are the same list).
can_go_back
fn can_go_back(self: &Self) -> bool
Gets whether the back stack has an entry.
can_go_forward
fn can_go_forward(self: &Self) -> bool
Gets whether the forward stack has an entry.
back_stack_depth
fn back_stack_depth(self: &Self) -> i32
Gets the number of entries of the back stack.
source_page_type
fn source_page_type(self: &Self) -> Option<PageType>
Gets the type of the page of the last navigation recorded in the journal.
current_source_page_type
fn current_source_page_type(self: &Self) -> Option<PageType>
Gets the type of the page the frame shows, as recorded in the journal.
cache_size
fn cache_size(self: &Self) -> i32
Gets the number of pages of the cache mode Enabled the frame keeps.
is_navigation_stack_enabled
fn is_navigation_stack_enabled(self: &Self) -> bool
Gets whether navigations are recorded in the journal.
set_is_navigation_stack_enabled
fn set_is_navigation_stack_enabled(self: &Self, value: bool)
Sets whether navigations are recorded in the journal.
current_page
fn current_page(self: &Self) -> Option<Ref<FramePage>>
Gets the page the frame shows.
set_cache_size
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.
set_source_page_type
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.
register_page_factory
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.
unregister_page_factory
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.
navigate
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.
navigate_to_type
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.
go_back
fn go_back(self: &Self) -> Result<(), NavigationError>
Navigates to the newest entry of the back stack (WinUI's GoBack).
go_forward
fn go_forward(self: &Self) -> Result<(), NavigationError>
Navigates to the newest entry of the forward stack (WinUI's GoForward).
navigating
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.
navigated
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.
navigation_stopped
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.
navigation_failed
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTemplatedControlImplExtContentControlImplExtControlImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<Frame>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleStyledElementImplVisualImplLayoutableImplInteractiveImplInputElementImplControlImplTemplatedControlImplContentControlImplFerroObjectImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.