Advice for dockable windows and regions?

Sep 4, 2008 at 11:12 PM
Hello,

I'm using a nice docking control (Sandock from divelements).  However, my program 'Blue Screens' my box when I drag a dockable window to another portion of the screen. 

In my app, when I attempt to move a dockable window (let's say from the right side of my screen to dock on the left) ... an exception is thrown within this block of code:

public class ContentControlRegionAdapter : RegionAdapterBase<ContentControl>
    {
        /// <summary>
        /// Adapts a <see cref="ContentControl"/> to an <see cref="IRegion"/>.
        /// </summary>
        /// <param name="region">The new region being used.</param>
        /// <param name="regionTarget">The object to adapt.</param>
        protected override void Adapt(IRegion region, ContentControl regionTarget)
        {
            if (regionTarget.Content != null || (BindingOperations.GetBinding(regionTarget, ContentControl.ContentProperty) != null))
                throw new InvalidOperationException(Resources.ContentControlHasContentException);

            region.ActiveViews.CollectionChanged += delegate
            {
                regionTarget.Content = region.ActiveViews.FirstOrDefault();
            };
        }

        /// <summary>
        /// Creates a new instance of <see cref="SingleActiveRegion"/>.
        /// </summary>
        /// <returns>A new instance of <see cref="SingleActiveRegion"/>.</returns>
        protected override IRegion CreateRegion()
        {
            return new SingleActiveRegion();
        }
    }

This is the line of code that throws the error:

if (regionTarget.Content != null || (BindingOperations.GetBinding(regionTarget, ContentControl.ContentProperty) != null))

This is the error text:
ContentControl's Content property is not empty.
    This control is being associated with a region, but the control is already bound to something else.
    If you did not explicitly set the control's Content property,
    this exception may be caused by a change in the value of the inherited RegionManager attached property.

In other words, it seems I am dragging one of the dockable windows to a different 'region' with the composite app and viola, problem occurs ...

Any ideas, suggestions or advice?

Sep 27, 2008 at 6:28 AM
I am having the same problem. I have an infragistics docking control. Any control with region manager attached property throw the above exception, when attempting to dock, attach, hide .. the content pane.

Any ideas would be welcome.
Sep 28, 2008 at 12:00 AM
I believe this is happening because the Dock control is changing the logical tree when moving views around.
This makes the RegionManager attached property (which inherits its value from parent controls) on the control that has a RegionName attached property change its value constantly when moving it, triggering a behavior to attach a new region on that control.
One possible way to stop the RegionManager attached property on the control to continually change its value when moving it, is to explicitly set its value, instead on relying on the logical tree for value inheritance.

For example:
<ItemsControl RegionName="MyThrowingExceptionRegion" RegionManager="{StaticResource RegionManager}" />

In the example you would have to register RegionManager as a resource, but you could also use binding or any other approach.

Please let me know if this helps,
Julian Dominguez
http://blogs.southworks.net/jdominguez
Oct 21, 2008 at 12:52 PM
Julian:

thank you for the information. I tried setting the regionmanager attached property on the control, but it throws an exception when the module gets loaded and is trying to resolve the view. The code snippet is from my Shell_View/Shell_ViewModel, where I have a property in the Shell_VM which exposes the IRegionManager, and dont have any scoped region managers.

The module, when loading uses,
                    IRegion iRegion = RegionManager.Regions[RegionNames.ConfigureRegion];
to determine the region. But utils:RegionNames.ConfigureRegion does not exist in the dictionary.

                    <igDock:SplitPane Name="Region2"
                                      igDock:XamDockManager.InitialLocation="DockedLeft"
                                      Focusable="False">
                        <igDock:TabGroupPane Name="Configure"
                                             AllowDrop="False"
                                             BorderThickness="1"
                                             cal:RegionManager.RegionManager="{Binding Path=MyRegionManager}"
                                             cal:RegionManager.RegionName="{x:Static utils:RegionNames.ConfigureRegion}">
                        </igDock:TabGroupPane>
                    </igDock:SplitPane>

Resolution of the dependency failed, type = "ConfigurationController", name = "". Exception message is: The current build operation (build key Build Key[ProjectTemp.ConfigurationModule.Controller.ConfigurationController, null]) failed: The given key was not present in the dictionary. (Strategy type Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy, index 2)


when I change it to use a static resource as you had shown,      <cal:RegionManager x:Key="regionManger"/>
an exception is thrown when the Shell_ViewModel/View is being resolved.

Exception message is: The current build operation (build key Build Key[ProjectTemp.ShellVM, null]) failed: The parameter view could not be resolved when attempting to call constructor ProjectTemp.ShellVM(ProjectTemp.IShellView view, Microsoft.Practices.Composite.Events.IEventAggregator eventAggregator, Microsoft.Practices.Composite.Regions.IRegionManager regionManager). (Strategy type Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy, index 2)

what am I missing ?



Oct 22, 2008 at 8:41 AM
Hi

I am just converting a WPF CAB project to use Infragistics Dockable panels and I have the same problem when simply I unpinning a Panel. (which is a named CAB Region)

If you discover a solution (or even any extra information) do please update this, I will also do the same.

I am on an Infragistics course next week.. you can guess my first question to them !!!

cheers
Martin


Oct 22, 2008 at 9:53 AM
Edited Oct 22, 2008 at 10:47 AM
[removed some code, did not 100% work]
Oct 22, 2008 at 10:09 AM
Edited Oct 22, 2008 at 10:46 AM
[removed some code examples, did not 100% work]
Oct 22, 2008 at 6:10 PM
Hi nishanta.
Apparently the container cannot resolve the IShellView property from the container. Are you registering it in the container?
Jan 21, 2009 at 5:47 PM
Edited Jan 21, 2009 at 6:41 PM
EDIT: Sorry, This Looks to be fixed in the latest release

Hello,

I'm having the same problem as the original posters. I get this regardless of whether I use Infragistic's DockManager or DevComponents.

Does anyone know of a fix?

Regards

Paul.