I'm working on application using Prism and yours Q3 WPF controls. Unfortunately when I'm trying to dock control in another dock region the InvalidOperationException is thrown. Exception message says I should use ItemsControl.ItemsSource instead of ItemsSource and I really don`t known how to solve this.
Below you'll find my region adapter class, dockable view class and docking container declaration in main window
Region adapter
Dockable view
ExampleView class in design time also generate en error: Could not create an instance of type 'RadDocumentPane'
Views container:
It's critical for me, so I'll be appreciate for any help.
Regards,
MC.
Below you'll find my region adapter class, dockable view class and docking container declaration in main window
Region adapter
namespace LTD.Desktop.Common |
{ |
public class RadPaneGroupRegionAdapter : RegionAdapterBase<RadPaneGroup> |
{ |
public RadPaneGroupRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) |
: base(regionBehaviorFactory) |
{ |
} |
protected override void Adapt(IRegion region, RadPaneGroup regionTarget) |
{ |
region.Views.CollectionChanged += (s, e) => |
{ |
switch (e.Action) |
{ |
case NotifyCollectionChangedAction.Add: |
foreach (var item in e.NewItems.OfType<RadPane>()) |
{ |
regionTarget.AddItem(item, Telerik.Windows.Controls.Docking.DockPosition.Center); |
} |
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; |
default: |
break; |
} |
}; |
foreach (var view in region.Views.OfType<RadPane>()) |
{ |
regionTarget.Items.Add(view); |
} |
} |
protected override IRegion CreateRegion() |
{ |
return new AllActiveRegion(); |
} |
} |
} |
Dockable view
namespace LTD.Examples.Modularity.Views |
{ |
/// <summary> |
/// Interaction logic for ExampleView.xaml |
/// </summary> |
public partial class ExampleView : RadDocumentPane |
{ |
public ExampleView() |
{ |
InitializeComponent(); |
} |
} |
} |
<telerik:RadDocumentPane x:Class="LTD.Examples.Modularity.Views.ExampleView" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" |
Header="Example panel"/> |
ExampleView class in design time also generate en error: Could not create an instance of type 'RadDocumentPane'
Views container:
<!-- Workspaces container --> |
<telerik:RadDocking Name="Workspaces" DockPanel.Dock="Bottom" cal:RegionManager.RegionName="Workspaces"> |
<telerik:RadDocking.DocumentHost> |
<telerik:RadSplitContainer> |
<telerik:RadPaneGroup cal:RegionManager.RegionName="MainRegion" /> |
</telerik:RadSplitContainer> |
</telerik:RadDocking.DocumentHost> |
</telerik:RadDocking> |
It's critical for me, so I'll be appreciate for any help.
Regards,
MC.