ListViewProperty
This is a BindableProperty
used when declaring bindings for ListView
.
How to Declare
As with BindableProperty
, you can declare by calling ListViewProperty<T>.Create()
.
private static readonly ListViewProperty<AlarmInfoViewModel> ListDataSourceProperty =
ListViewProperty<AlarmInfoViewModel>.Create(
itemViewId: AlarmInfoLayout.UxmlGuid,
makeItemSource: MakeItem,
itemsSourcePath: PropertyPath.FromName(nameof(AlarmInfoListViewModel.Current)),
elementNameInfo: ElementNames.AlarmsList
);
private static AlarmInfoViewModel MakeItem(int index)
{
var newInfo = new AlarmInfo
{
isEnabled = true,
id = Guid.NewGuid().ToString(),
info = $"Alarm {index + 1}",
timeStringIso8601 = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:sszzz"),
};
return new AlarmInfoViewModel(newInfo);
}
Parameters
TabViewProperty<T>.Create()
can specify the following parameters:
Parameter | Type | Required | Default Value |
---|---|---|---|
itemViewId | string | yes | - |
makeItemSource | MakeItemSourceDelegate | yes | - |
itemsSourcePath | PropertyPath | yes | - |
elementNameInfo | ElementNameInfo | yes | - |
bindingMode | BindingMode | no | BindingMode.ToTarget |
updateTrigger | BindingUpdateTrigger | no | BindingUpdateTrigger.OnSourceChanged |
itemViewId
Specifies the Guid of the View class. For the assembly containing the View class with the specified Guid, you need to callViewInstaller.Install()
in advance. InListView.makeItem
, this Guid is used to obtain and instantiate aVisualTreeAsset
, and data binding is executed by the View class.makeItemSource
Defines how to create the contents ofitemsSource
whenListView.bindItem
is triggered.
The result of the process specified bymakeItemSource
becomes the data source for each item in theListView
.elementNameInfo
Specifies whichListView
to construct the binding for.bindingMode
SpecifiesBindingMode
.updateTrigger
SpecifiesBindingUpdateTrigger
.