/
solostacktoolkit
/
novaflowwpf
Обзор
Документация
Войти
/
solostacktoolkit
/
novaflowwpf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Controls/DropPanel.xaml.cs
71 строка
2 KB
Артем Зиновьев
Добавлен Demo
06 мар 2026, 23:48
06 мар 2026, 23:48
772764d
Код
Авторство
О чём код?
using System; using System.Collections; using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace NovaFlow.Controls; /// <summary> /// Элегантная раскрывающаяся панель с анимацией и поддержкой команд /// </summary> public partial class DropPanel : UserControl { public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(DropPanel), new PropertyMetadata(string.Empty)); public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register(nameof(Items), typeof(IEnumerable), typeof(DropPanel), new PropertyMetadata(null, OnItemsChanged)); public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register(nameof(IsExpanded), typeof(bool), typeof(DropPanel), new PropertyMetadata(false)); public static readonly DependencyProperty ItemSelectedCommandProperty = DependencyProperty.Register(nameof(ItemSelectedCommand), typeof(ICommand), typeof(DropPanel), new PropertyMetadata(null)); public string Header { get => (string)GetValue(HeaderProperty); set => SetValue(HeaderProperty, value); } public IEnumerable Items { get => (IEnumerable)GetValue(ItemsProperty); set => SetValue(ItemsProperty, value); } public bool IsExpanded { get => (bool)GetValue(IsExpandedProperty); set => SetValue(IsExpandedProperty, value); } public ICommand ItemSelectedCommand { get => (ICommand)GetValue(ItemSelectedCommandProperty); set => SetValue(ItemSelectedCommandProperty, value); } public DropPanel() { InitializeComponent(); Loaded += OnLoaded; } private void OnLoaded(object sender, RoutedEventArgs e) { if (ItemsControl != null) ItemsControl.ItemsSource = Items; } private static void OnItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is DropPanel panel && panel.ItemsControl != null) panel.ItemsControl.ItemsSource = e.NewValue as IEnumerable; } }