Show / Hide Table of Contents

Class TreeViewModel<T>

A view model for managing items in a TreeView.

Inheritance
object
BindableBase
TreeViewModel<T>
BotTreeViewModel
ListViewModel<T>
ScenarioTreeViewModel
Implements
INotifyPropertyChanged
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
INotifyCollectionChanged
Inherited Members
BindableBase.SetProperty<T>(ref T, T, string)
BindableBase.SetProperty<T>(ref T, T, Action, string)
BindableBase.RaisePropertyChanged(string)
BindableBase.OnPropertyChanged(PropertyChangedEventArgs)
BindableBase.PropertyChanged
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Phoenix.BotBrain.Controls
Assembly: Phoenix.Plugin.BotBrain.Lists.dll
Syntax
public class TreeViewModel<T> : BindableBase, INotifyPropertyChanged, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged where T : class
Type Parameters
Name Description
T

The item type.

Constructors

View Source

TreeViewModel(IServiceProvider?)

Initializes a new instance of the TreeViewModel<T> class.

Declaration
public TreeViewModel(IServiceProvider? serviceProvider = null)
Parameters
Type Name Description
IServiceProvider serviceProvider

The service provider for creating items.

Properties

View Source

AddItemCommand

Gets the command for adding an item.

Declaration
public DelegateCommand<object> AddItemCommand { get; }
Property Value
Type Description
DelegateCommand<object>
View Source

AddWithPopup

Gets or sets a value indicating whether or not the create button uses a popup menu of available items.

Declaration
public bool AddWithPopup { get; set; }
Property Value
Type Description
bool
View Source

AvailableItems

Gets or sets the available items to display in the create item popup menu.

Declaration
public ICollectionView? AvailableItems { get; set; }
Property Value
Type Description
ICollectionView
View Source

AvailableItemsDisplayMemberPath

Gets or sets the property name to display for items to create in the popup menu.

Declaration
public string? AvailableItemsDisplayMemberPath { get; set; }
Property Value
Type Description
string
View Source

CanAdd

Gets a value indicating whether or not items can be added.

Declaration
public bool CanAdd { get; }
Property Value
Type Description
bool
View Source

CanClear

Gets a value indicating whether or not items all items can be cleared at once.

Declaration
public bool CanClear { get; }
Property Value
Type Description
bool
View Source

ClearAllItemsCommand

Gets the command for clearing all items.

Declaration
public DelegateCommand ClearAllItemsCommand { get; }
Property Value
Type Description
DelegateCommand
View Source

Count

Gets the number of elements in the collection.

Declaration
public int Count { get; }
Property Value
Type Description
int

The number of elements in the collection.

View Source

CreateItemFunc

Gets or sets a function for use with the AddWithPopup option to create the item selected by the user.

Declaration
public Func<object?, T?>? CreateItemFunc { get; set; }
Property Value
Type Description
Func<object, T>
View Source

IsClearable

Gets or sets a value indicating whether or not all items can be removed at once.

Declaration
public bool IsClearable { get; set; }
Property Value
Type Description
bool
View Source

IsEditable

Gets or sets a value indicating whether or not items can be added, moved, or removed.

Declaration
public bool IsEditable { get; set; }
Property Value
Type Description
bool
View Source

IsSorted

Gets or sets a value indicating whether or not to sort items added to the tree.

Declaration
public bool IsSorted { get; set; }
Property Value
Type Description
bool
View Source

Items

Gets the list of items.

Declaration
public List<T> Items { get; }
Property Value
Type Description
List<T>
View Source

RemoveItemsCommand

Gets the command for removing items.

Declaration
public DelegateCommand<object> RemoveItemsCommand { get; }
Property Value
Type Description
DelegateCommand<object>
View Source

RemoveSelectedItemCommand

Gets the command for removing the selected item.

Declaration
public DelegateCommand RemoveSelectedItemCommand { get; }
Property Value
Type Description
DelegateCommand
View Source

RemoveSubItemFunc

Gets or sets a function for use with the button to remove sub-items from the tree.

Declaration
public Action<T>? RemoveSubItemFunc { get; set; }
Property Value
Type Description
Action<T>
View Source

SelectedItem

Gets or sets the currently selected item.

Declaration
public T? SelectedItem { get; set; }
Property Value
Type Description
T
View Source

Services

Gets or sets the export provider used to construct a default item.

Declaration
public IServiceProvider? Services { get; set; }
Property Value
Type Description
IServiceProvider

Methods

View Source

AddItem(object)

Adds the given item.

Declaration
public void AddItem(object arg)
Parameters
Type Name Description
object arg

The item identifier.

View Source

AddItem(T?)

Adds the given item.

Declaration
public void AddItem(T? item)
Parameters
Type Name Description
T item

The item.

View Source

ClearAllItems()

Removes all items.

Declaration
public virtual void ClearAllItems()
View Source

CreateItem(object?)

Creates an item with the given identifier, or a default one.

Declaration
public T? CreateItem(object? arg = null)
Parameters
Type Name Description
object arg

The item identifier.

Returns
Type Description
T

The item.

View Source

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
IEnumerator<T>

An enumerator that can be used to iterate through the collection.

View Source

InsertItem(int, T?)

Inserts the given item.

Declaration
public void InsertItem(int index, T? item)
Parameters
Type Name Description
int index

The index to insert at.

T item

The item.

View Source

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises a collection changed event.

Declaration
protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
Type Name Description
NotifyCollectionChangedEventArgs e

The event args.

View Source

RemoveItem(T?)

Removes the given item.

Declaration
public virtual void RemoveItem(T? item)
Parameters
Type Name Description
T item

The item.

View Source

RemoveItems(IEnumerable<T>)

Removes the given items.

Declaration
public void RemoveItems(IEnumerable<T> items)
Parameters
Type Name Description
IEnumerable<T> items

The items.

View Source

SynchronizeTo<T2>(IEnumerable<T2>, Func<T, T2>, Action<T2>, Action<T2>)

Adds/removes items in the target collection, such that it matches this view.

Declaration
public void SynchronizeTo<T2>(IEnumerable<T2> target, Func<T, T2> extractItem, Action<T2> addItem, Action<T2> removeItem)
Parameters
Type Name Description
IEnumerable<T2> target

The target collection.

Func<T, T2> extractItem

A function to extract an item from the view.

Action<T2> addItem

A function to add an item to the target collection.

Action<T2> removeItem

A function to remove an item to the target collection.

Type Parameters
Name Description
T2

The item type.

Events

View Source

CollectionChanged

Occurs when the collection changes.

Declaration
public event NotifyCollectionChangedEventHandler? CollectionChanged
Event Type
Type Description
NotifyCollectionChangedEventHandler

Implements

INotifyPropertyChanged
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
INotifyCollectionChanged

Extension Methods

IEnumerableExtensions.WithoutLast<T>(IEnumerable<T>)
INotifyCollectionChangedExtensions.OnItemAdded(INotifyCollectionChanged, Action<object?>)
INotifyCollectionChangedExtensions.OnItemAdded<T2>(INotifyCollectionChanged, Action<T2>)
INotifyPropertyChangedExtensions.OnPropertyChanged(INotifyPropertyChanged, string, Action)
INotifyPropertyChangedExtensions.OnPropertyChanged(INotifyPropertyChanged, string, Action<object?, string>)
INotifyPropertyChangedExtensions.OnPropertyChangedUntil(INotifyPropertyChanged, string, Func<bool>)
INotifyPropertyChangedExtensions.OnPropertyChangedUntil(INotifyPropertyChanged, string, Func<object?, string, bool>)
  • View Source
In this article
Back to top Generated by DocFX