This is a migrated thread and some comments may be shown as answers.

Rad Docking with Prism Issue.

2 Answers 68 Views
Docking
This is a migrated thread and some comments may be shown as answers.
muhammad
Top achievements
Rank 1
muhammad asked on 12 Sep 2012, 02:50 PM
Hi,
    I am using RadDocking control in my prism application. I have created RadGroupPane addapter. Its working fine for a group pane if Its docked state, But if I change the state and try to add new view in my group pane then it throws an exception that index for region does not exist or out of index. "Insertion index was out of range. Must be non-negative and less than or equal to size.\r\nParameter name: index". is that a know issue, Can any one suggest me the solution for the problem please. The Adapter code is as follows:

public class DockManagerAdapter : RegionAdapterBase<RadPaneGroup>
{
protected override void Adapt(IRegion region, RadPaneGroup regionTarget)
        {
            region.ActiveViews.CollectionChanged += (s, e) =>
            {
                switch (e.Action)
                {
                    case NotifyCollectionChangedAction.Add:
                        foreach (var item in e.NewItems.OfType<RadPane>())
                        {
                            regionTarget.Items.Add(item);
                        }
                        break;
                    case NotifyCollectionChangedAction.Remove:
                        foreach (var item in e.OldItems.OfType<RadPane>())
                        {
                            item.RemoveFromParent();
                        }
                        break;
                    case NotifyCollectionChangedAction.Replace:
                        var oldItems = e.OldItems.OfType<RadPane>();
                        var newItems = e.NewItems.OfType<RadPane>();
                        var newItemsEnumerator = newItems.GetEnumerator();
                        foreach (var oldItem in oldItems)
                        {
                            var parent = oldItem.Parent as ItemsControl;
                            if (parent != null && parent.Items.Contains(oldItem))
                            {
                                parent.Items[parent.Items.IndexOf(oldItem)] = newItemsEnumerator.Current;
                                if (!newItemsEnumerator.MoveNext())
                                {
                                    break;
                                }
                            }
                            else
                            {
                                oldItem.RemoveFromParent();
                                regionTarget.Items.Add(newItemsEnumerator.Current);
                            }
                        }
                        break;
                    case NotifyCollectionChangedAction.Reset:
                        regionTarget
                            .EnumeratePanes()
                            .ToList()
                            .ForEach(p => p.RemoveFromParent());
                        break;
                }
            };


            foreach (var view in region.Views.OfType<RadPane>())
            {
                regionTarget.Items.Add(view);
            }
        }
protected override IRegion CreateRegion()
        {
            return new SingleActiveRegion();
        }
}

Regards,


2 Answers, 1 is accepted

Sort by
0
muhammad
Top achievements
Rank 1
answered on 13 Sep 2012, 11:22 AM
Hi,
   After investigation of my code I have found that problem is not with adapter. Actually they way I am trying to create regions and trying to map them with adapter is not working. 

 I have created a content control and declared it as a prism region in my shell application and in module class derived from Imodule interface while initialization I am adding view to my region which is working fine. But the registered view is a user control containing rad docking and rest of RadPaneGroup and each RadPaneGroup into the view is a Prism Region. These regions are accessible through region manager if in bootstrapper while configuring adapter I map user control with adapter not the radpanegroup. But then the adapter class's adapt method does not execute on add remove panes in radpanegroup. 

 Now my question is that how can I map nested prism region define in user control in above scenario with adapter class? Can anyone suggest something in this regard thanks.

Regards.
0
George
Telerik team
answered on 18 Sep 2012, 11:10 AM
Hi,

I prepared a sample to test the given scenario - you can find it attached. Can you refer to the project and let me know if this helps? I am glad to assist you further.

Regards,
George
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
Docking
Asked by
muhammad
Top achievements
Rank 1
Answers by
muhammad
Top achievements
Rank 1
George
Telerik team
Share this question
or