55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
|
|
namespace Avalonia.PropertyGrid.Models;
|
|
|
|
/// <summary>
|
|
/// Represents a category group in the PropertyGrid
|
|
/// </summary>
|
|
public class CategoryGroup : INotifyPropertyChanged
|
|
{
|
|
private bool _isExpanded = true;
|
|
|
|
/// <summary>
|
|
/// Occurs when a property value changes.
|
|
/// </summary>
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
/// <summary>
|
|
/// The category name
|
|
/// </summary>
|
|
public string CategoryName { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Properties in this category
|
|
/// </summary>
|
|
public ObservableCollection<PropertyItem> Properties { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Whether the category is expanded
|
|
/// </summary>
|
|
public bool IsExpanded
|
|
{
|
|
get => _isExpanded;
|
|
set
|
|
{
|
|
if (_isExpanded != value)
|
|
{
|
|
_isExpanded = value;
|
|
OnPropertyChanged(nameof(IsExpanded));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Number of properties in this category
|
|
/// </summary>
|
|
public int PropertyCount => Properties.Count;
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|