private static void UpdateItemsView(ItemsControl sender, AvaloniaPropertyChangedEventArgs e) { if (e.NewValue is null) { sender.ItemsPanel = ItemsControl.ItemsPanelProperty.GetDefaultValue(sender.GetType()); sender.DataTemplates.Clear(); return; } var view = (ItemsControlView)e.NewValue; sender.ItemsPanel = view.PanelTemplate; sender.DataTemplates.Clear(); sender.DataTemplates.AddRange(view.DataTemplates); var template = sender.GetBaseValue(TemplatedControl.TemplateProperty, BindingPriority.LocalValue); sender.SetValue(TemplatedControl.TemplateProperty, null); sender.ApplyTemplate(); if (template.HasValue) { sender.SetValue(TemplatedControl.TemplateProperty, template.Value); } else { sender.ClearValue(TemplatedControl.TemplateProperty); } sender.ApplyTemplate(); }
private static void RestoreOriginalStyles([NotNull] ItemsControl listBox) { if (!(listBox.GetValue(_originalStylesProperty) is OriginalStyles originalStyles)) { return; } listBox.ClearValue(_originalStylesProperty); listBox.Style = originalStyles.Style; listBox.ItemContainerStyle = originalStyles.ItemContainerStyle; listBox.ItemTemplate = originalStyles.ItemTemplate; }
private static void ClearItemsControlManager(ItemsControl itemsControl) { itemsControl.ClearValue(ItemsControlManagerProperty); }