FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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.

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

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

    Returns a strong reference to this object.

    Source

    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).

    Source

    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).

    Source

    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

    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).

    Source

    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).

    Source

    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.

    Source

    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.

    Source

    construct

    fn construct() -> Self
    

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

    Source

    new

    fn new() -> Ref<Self>
    

    Creates a frame with an empty journal.

    Source

    back_stack

    fn back_stack(self: &Self) -> NavigationStack
    

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

    Source

    forward_stack

    fn forward_stack(self: &Self) -> NavigationStack
    

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

    Source

    can_go_back

    fn can_go_back(self: &Self) -> bool
    

    Gets whether the back stack has an entry.

    Source

    can_go_forward

    fn can_go_forward(self: &Self) -> bool
    

    Gets whether the forward stack has an entry.

    Source

    back_stack_depth

    fn back_stack_depth(self: &Self) -> i32
    

    Gets the number of entries of the back stack.

    Source

    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.

    Source

    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.

    Source

    cache_size

    fn cache_size(self: &Self) -> i32
    

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

    Source

    is_navigation_stack_enabled

    fn is_navigation_stack_enabled(self: &Self) -> bool
    

    Gets whether navigations are recorded in the journal.

    Source

    set_is_navigation_stack_enabled

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

    Sets whether navigations are recorded in the journal.

    Source

    current_page

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

    Gets the page the frame shows.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    go_back

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

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

    Source

    go_forward

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

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

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.