Ejemplo n.º 1
0
        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var group    = d as RadPaneGroup;
            var oldValue = e.OldValue as IEnumerable <RadPane>;
            var newValue = e.NewValue as IEnumerable <RadPane>;
            var oldValueObservableCollection = e.OldValue as INotifyCollectionChanged;
            var newValueObservableCollection = e.NewValue as INotifyCollectionChanged;

            if (group != null)
            {
                var extension = GetPaneGroupExtension(group);
                if (extension == null)
                {
                    extension = new PaneGroupExtensions {
                        Group = group
                    };
                    SetPaneGroupExtension(group, extension);
                }

                if (oldValue != null)
                {
                    foreach (var pane in oldValue)
                    {
                        pane.RemoveFromParent();
                    }

                    if (oldValueObservableCollection != null)
                    {
                        oldValueObservableCollection.CollectionChanged -= extension.OnItemsSourceCollectionChanged;
                    }
                }

                if (newValue != null)
                {
                    foreach (var pane in newValue)
                    {
                        group.Items.Add(pane);
                    }

                    if (newValueObservableCollection != null)
                    {
                        newValueObservableCollection.CollectionChanged += extension.OnItemsSourceCollectionChanged;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private static void SetPaneGroupExtension(DependencyObject obj, PaneGroupExtensions value)
 {
     obj.SetValue(PaneGroupExtensionProperty, value);
 }