Skip to main content

ItemsSourceView

Struct ItemsSourceView 

Source
pub struct ItemsSourceView { /* private fields */ }
Expand description

Represents a standardized view of the supported interactions between an items collection and an items control.

Implementations§

Source§

impl ItemsSourceView

Source

pub fn empty() -> Rc<ItemsSourceView>

Gets an empty ItemsSourceView.

Source

pub fn new(source: ItemsSource) -> Rc<Self>

Initializes a new instance of the view for the specified data source.

Source

pub fn count(&self) -> usize

Gets the number of items in the collection.

Source

pub fn has_key_index_mapping(&self) -> bool

Gets a value that indicates whether the items source can provide a unique key for each item: whether the source implements IKeyIndexMapping (WinUI ItemsSourceView.HasKeyIndexMapping).

Source

pub fn key_from_index(&self, index: i32) -> String

Retrieves the unique key of the item at index from the items source (WinUI ItemsSourceView.KeyFromIndex).

Panics if the source does not implement IKeyIndexMapping (WinUI throws hresult_not_implemented), or if index is not the index of an item.

Source

pub fn index_from_key(&self, key: &str) -> i32

Retrieves the index of the item that has the unique key key, or -1 when no item has it (WinUI ItemsSourceView.IndexFromKey).

Panics if the source does not implement IKeyIndexMapping (WinUI throws hresult_not_implemented).

Source

pub fn source(&self) -> ItemsSource

Gets the source collection.

Source

pub fn add_collection_changed(&self, handler: Rc<ItemsChangedHandler>) -> u64

Occurs when the collection has changed to indicate the reason for the change and which items changed. Returns the token for remove_collection_changed.

Source

pub fn remove_collection_changed(&self, token: u64)

Source

pub fn get_at(&self, index: usize) -> Option<BoxedValue>

Retrieves the item at the specified index. Panics if out of range.

Source

pub fn contains(&self, item: &Option<BoxedValue>) -> bool

Whether the collection contains the item.

Source

pub fn index_of(&self, item: &Option<BoxedValue>) -> i32

The index of the item, or -1.

Source

pub fn get_or_create(items: Option<&ItemsSource>) -> Rc<ItemsSourceView>

Gets or creates an ItemsSourceView for the specified source.

Returns empty if items is None, the view itself if items is a view (ItemsSourceView isv => isv), otherwise a new view.

Source

pub fn get_or_create_of<T: PropertyValue>( items: Option<&ItemsSource>, ) -> ItemsSourceViewOf<T>

Gets or creates a typed view for the specified source.

Source

pub fn iter(&self) -> impl Iterator<Item = Option<BoxedValue>>

The items, enumerated by index over the live collection.

Source

pub fn to_vec(&self) -> Vec<Option<BoxedValue>>

A copy of the items.

Trait Implementations§

Source§

impl ICollectionChangedListener for ItemsSourceView

Source§

impl IItemsList for ItemsSourceView

A view is a list of items itself (upstream ItemsSourceView : IReadOnlyList<object?>, IList, INotifyCollectionChanged): it can be the items source of a control, which then reads the items and the changes through the view, and ItemsSourceView::get_or_create returns it as it is. Its unique keys are those of its source.

Source§

fn key_index_mapping(&self) -> Option<&dyn IKeyIndexMapping>

The unique keys of the items, if the list provides them (IKeyIndexMapping); None by default. An index is never a key: a list without keys has none.
Source§

fn count(&self) -> usize

The number of items.
Source§

fn get_at(&self, index: usize) -> Option<BoxedValue>

The item at index. Panics if out of range.
Source§

fn index_of(&self, item: &Option<BoxedValue>) -> i32

The index of the first item equal to item, or -1.
Source§

fn is_notifying(&self) -> bool

Whether the list notifies of changes.
Source§

fn add_collection_changed( &self, handler: Rc<ItemsChangedHandler>, ) -> Option<u64>

Subscribes to changes. Returns the token for remove_collection_changed, or None if the list does not notify.
Source§

fn remove_collection_changed(&self, token: u64)

Unsubscribes a handler.
Source§

fn as_any(&self) -> &dyn Any

The collection as Any, to get back to the typed collection.
Source§

fn identity(&self) -> Option<usize>

The identity of the collection, for a list that is a handle to a collection (a FerroList): two handles to one collection are the same collection. None for a list that is the collection itself, whose identity is its address.
Source§

impl IKeyIndexMapping for ItemsSourceView

Source§

fn key_from_index(&self, index: i32) -> String

Retrieves the unique key of the item at the specified index.
Source§

fn index_from_key(&self, key: &str) -> i32

Retrieves the index of the item that has the specified unique key, or -1 when no item has it.
Source§

impl MarkupTyped for ItemsSourceView

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl PartialEq for ItemsSourceView

A view is a reference: two views are equal when they are the same view.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.